-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
47 lines (33 loc) · 1.81 KB
/
index.js
File metadata and controls
47 lines (33 loc) · 1.81 KB
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
const { Client, Collection, Intents } = require('discord.js');
const client = global.client = new Client({ allowedMentions: { parse: ['users', 'roles'], repliedUser: true },
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_PRESENCES, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MEMBERS]
});
const set = require("./settings.json");
client.login(set.token).catch(err => {console.error("The token is incorrect or you forgot to enter the token!")});
client.commands = new Collection();
const { readdirSync } = require("fs");
const { join } = require("path");
const commandFiles = readdirSync(join(__dirname, "Commands")).filter(file => file.endsWith(".js"));
for (const file of commandFiles) {
const command = require(join(__dirname, "Commands", `${file}`));
client.commands.set(command.code, command)
console.log('[ '+command.code+' ] adlı komut başarıyla çalışıyor.');
}
readdirSync("./Events").filter(file => file.endsWith(".js")).forEach(file => {
let event = require(`./Events/${file}`);
client.on(event.conf.event, event.execute);
console.log(` { ${file.replace(".js", "") } } adlı event başarıyla çalışıyor.`);
});
client.once("ready", async() => {
console.log("Bot Başarıyla giriş yaptı!")
});
client.on("messageCreate", async (message) => {
if(message.author.bot) return;
if(message.content.startsWith(set.prefix)) {
const args = message.content.slice(set.prefix.length).trim().split(/ +/);
const command = args.shift().toLowerCase();
var cmd = client.commands.get(command) || client.commands.array().find((x) => x.aliases && x.aliases.includes(command));
if(!cmd) return message.channel.send(`Komut dosyamda **${command}** adlı bir komut bulamadım.`);
try { cmd.run(client, message, args, set); } catch (error){ console.error(error); }
}
});