dcjs-command-handler
Version:
Command Handler For Discord Bots
37 lines (24 loc) • 1.03 kB
JavaScript
const {Collection} = require('discord.js');
const Client = require("./YSteelX/Client.js");
const Command = require("./YSteelX/Command.js");
//const client = new Client({ intents: Object.values(Intents.FLAGS).reduce((p, c) => p + c, 0)})
const client = new Client()
client.commands = new Collection()
// Command Handler;
const fs = require('fs')
fs.readdirSync("./komutlar")
.filter(file => file.endsWith('.js'))
.forEach(file=>{
/**@type {Command} */
const komut = require(`./komutlar/${file}`)
console.log(`${komut.isim} Adlı Komut Yüklendi!`)
client.commands.set(komut.isim,komut.digerisim,komut)
})
client.on('messageCreate', message =>{
if(message.author.bot) return
if(!message.content.startsWith(ayar.prefix)) return
const args = message.content.substring(ayar.prefix.length).split(/ +/);
const command = client.commands.find(cmd => cmd.isim == args[0])
if(!command) return message.reply('Böyle Bir Komudum Yok!')
command.run(message, args , client)
})