-
Notifications
You must be signed in to change notification settings - Fork 2
/
ertu.js
120 lines (102 loc) · 4.66 KB
/
ertu.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
const { Client, Partials, GatewayIntentBits, Events, EmbedBuilder, ActivityType, Collection, PermissionsBitField } = require('discord.js');
const system = require('./System');
const { readdir } = require('fs');
const { joinVoiceChannel } = require('@discordjs/voice');
const linkCooldowns = new Map();
const reklamCooldowns = new Map();
const client = global.client = new Client({ intents: Object.keys(GatewayIntentBits), partials: Object.keys(Partials) });
const commands = client.commands = new Collection();
const aliases = client.aliases = new Collection();
readdir("./Commands/", (err, files) => {
if (err) console.error(err)
files.forEach(f => {
readdir("./Commands/" + f, (err2, files2) => {
if (err2) console.log(err2)
files2.forEach(file => {
let ertucum = require(`./Commands/${f}/` + file);
console.log(`[KOMUT] ${ertucum.name} Yüklendi!`);
commands.set(ertucum.name, ertucum);
ertucum.aliases.forEach(alias => { aliases.set(alias, ertucum.name); });
});
});
});
});
readdir("./Events/", (err, files) => {
if (err) console.error(err)
files.forEach(f => {
require(`./Events/${f}`);
console.log(`[EVENT] (${f.replace(".js", "")})`)
});
});
client.on(Events.MessageCreate, async (message) => {
const reklamRegex = /discord\.gg\/\w+|discordapp\.com\/invite\/\w+/gi;
if (reklamRegex.test(message.content) && !message.member.permissions.has(PermissionsBitField.Flags.Administrator)) {
if (!reklamCooldowns.has(message.author.id)) {
reklamCooldowns.set(message.author.id, 1);
} else {
reklamCooldowns.set(message.author.id, reklamCooldowns.get(message.author.id) + 1);
}
if (reklamCooldowns.get(message.author.id) >= 5) {
message.member.timeout(300000);
reklamCooldowns.delete(message.author.id);
message.delete();
message.channel.send(`${message.author} 5 adet reklam yaptığı için 5 dakika susturuldu!`).then(s => setTimeout(() => s.delete().catch(err => { }), 5000));
}
if (reklamCooldowns.get(message.author.id) <= 5) {
message.delete();
message.channel.send(`${message.author}, reklam yapmak yasaktır!`).then(s => setTimeout(() => s.delete().catch(err => { }), 5000));
}
return;
}
const linkRegex = /(https?|ftp):\/\/[^\s/$.?#].[^\s]*/gi;
if (linkRegex.test(message.content) && !message.member.permissions.has(PermissionsBitField.Flags.Administrator)) {
if (!linkCooldowns.has(message.author.id)) {
linkCooldowns.set(message.author.id, 1);
} else {
linkCooldowns.set(message.author.id, linkCooldowns.get(message.author.id) + 1);
}
if (linkCooldowns.get(message.author.id) >= 5) {
message.member.timeout(300000);
linkCooldowns.delete(message.author.id);
message.delete();
message.channel.send(`${message.author} 5 adet link paylaştığı için 5 dakika susturuldu!`).then(s => setTimeout(() => s.delete().catch(err => { }), 5000));
}
if (linkCooldowns.get(message.author.id) <= 5) {
message.delete();
message.channel.send(`${message.author}, linkler yasaktır!`).then(s => setTimeout(() => s.delete().catch(err => { }), 5000));
}
return;
}
if (system.prefix && !message.content.startsWith(system.prefix)) return;
const args = message.content.slice(1).trim().split(/ +/g);
const commands = args.shift().toLowerCase();
const cmd = client.commands.get(commands) || [...client.commands.values()].find((e) => e.aliases && e.aliases.includes(commands));
if (cmd) {
cmd.execute(client, message, args);
}
})
client.on(Events.ClientReady, async () => {
console.log(`[BOT] ${client.user.tag} olarak giriş yaptı!`);
client.user.setActivity({ name: 'ertu was here ❤️', type: ActivityType.Listening });
client.user.setStatus('dnd');
const channel = client.channels.cache.get(system.botVoiceChannelId);
let vcStatus = joinVoiceChannel({
channelId: channel.id,
guildId: channel.guild.id,
adapterCreator: channel.guild.voiceAdapterCreator,
group: client.user.id,
selfDeaf: true,
selfMute: true
});
vcStatus.on('error', (err) => {
console.log(err);
vcStatus.rejoin();
});
});
const mongoose = require("mongoose");
mongoose.connect(system.mongoUrl, { useNewUrlParser: true, useUnifiedTopology: true }).then(() => {
console.log("[BOT] MongoDB bağlandı!")
}).catch((err) => {
throw err;
});
client.login(system.token);