-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
41 lines (30 loc) · 1.17 KB
/
index.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
const { Client, Intents } = require('discord.js');
const fs = require('fs');
const { token } = require('./config.json');
const { SlashCommandBuilder } = require('@discordjs/builders');
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
client.commands = new Map();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
if (!command.data || !command.execute) {
console.error(`Geçersiz komut dosyası: ${file}`);
continue;
}
client.commands.set(command.data.name, command);
}
client.once('ready', () => {
console.log(`Bot ${client.user.tag} olarak giriş yaptı.`);
});
client.on('interactionCreate', async interaction => {
if (!interaction.isCommand()) return;
const { commandName } = interaction;
if (!client.commands.has(commandName)) return;
try {
await client.commands.get(commandName).execute(interaction);
} catch (error) {
console.error(error);
await interaction.reply({ content: 'Komut yürütülürken bir hata oluştu.', ephemeral: true });
}
});
client.login(token);