v2.5.2
Giriş yap

npm discord.js modülü için fs ile command handler yapmak

mrturk
768 defa görüntülendi ve 1 kişi tarafından değerlendirildi

Sorunum

discord.js için yaptığım handlerdaki hatayı bulamadım, herşeyi eksiksiz yaptığımı biliyorum ama bir türlü cevap vermiyor bot

Modüller
Handler

const folders = fs.readdirSync("./commands/")

for (const files of folders) {
const folder = fs.readdirSync(`./commands/${files}/`).filter(file => file.endsWith(".js"))

for (const commands of folder) {
  const command = require(`./commands/${files}/${commands}`)
  console.log(`./commands/${files}/${commands}`)
    bot.on('message',message => {
        const args = message.content.slice(config.prefix.length).trim().split(/ +/);
        if(message.content !== `${config.prefix}${command.name}` || `${config.prefix}${command.aliases.join(' || ')}`) return;
        require(`./commands/${files}/${commands}`)(bot,message,args)
        if(message.author.bot) return;
        command.code
    })
  }
}
Örnek kullanım

Dosya yolu

./commands/user/ping.js
module.exports = {
    name: "ping",
    aliases: [],
    code: async (bot, message, args) => {
      message.channel.send('pong')
    }
  }

Önemli not

Cevap olarak hazır handler yazmayın , 'bot' tanımlanmıştır
hizlicevap
1022 gün önce

code property'sini function olarak çalıştırman gerekiyor.