Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

510
Visualizações
(DISCORD.JS) how do i fix my discord "cmds" command?

I was wondering how do I fix my "cmds" command? I can't seem to get it to work properly. It's supposed to get all the commands and add a field with the commands name and description to a embed but instead shows up with this error also the file tree is here

module.exports = {
    name:'cmds',
    description:'Literally shows the commands thats it.',
    aliases:'',
    execute(client,msg,args,blacklisted){
        const fs = require('fs')
        const {MessageEmbed} = require("discord.js")
        const embed = new MessageEmbed()
        function getCommand(cmd){
            return client.commands.get(`${cmd}`)
       }
       const commandFiles = fs.readdirSync('.').filter(file => file.endsWith('.js'));
       for (const file of commandFiles){
        const command = require(`./${file}`)
        embed.addField(command.name,```${command.description}```)
        }
        const author = msg.author
        const user = msg.mentions.members.first() || msg.author;
        const useronly = msg.mentions.users.first()
        if (blacklisted.includes(author.id)){
            msg.reply(`You have been blacklisted from using this bot. if you think this is a mistake contact the bot owner.`)
        }else{
        embed.setTitle(`Commands`)
        embed.setColor('RANDOM')
        msg.reply({embeds : [embed] })
        }
    }
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

i solved it own by doing this

 function getCommand(cmd){
        return client.commands.get(`${cmd}`)
   }
   console.log(getCommand('avatar').name)
    const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
    for (const file of commandFiles){
        const command = require(`./${file}`)
        embed.addField(`${command.name}`,`\`\`\ ${command.description} \`\`\ `)
    }
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda