Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

discord.js v13 message is not defiened?

I was using v12 now i’ve to upgrade v13 anyhow. Now i was trying slash commands. but i got an error same command is working fine on my prefix but in slash its not working.

client.on('messageCreate', message => {
    
    const guildId = "914573324485541928"
    const guild = client.guilds.cache.get(guildId)
    let commands

    if (guild) {
      commands = guild.commands
    } else {
      commands = client.application.commands
    }

    commands.create({
      name: 'ping',
      description: 'Replies with pong'
    })
    commands.create({
      name: 'truth',
      description: 'Replies with a random truth question'
    })
    commands.create({
      name: 'dare',
      description: 'Replies with a random dare question'
    })
    commands.create({
      name: 'truthbangla',
      description: 'Replies with a random bangla truth question'
    })
    commands.create({
      name: 'darebangla',
      description: 'Replies with a random bangla dare questions'
    })
    commands.create({
      name: 'invite',
      description: 'Get the invite link of this bot'
    })
    commands.create({
      name: 'help',
      description: 'Replies with all list of commands'
    })
    commands.create({
      name: 'vote',
      description: 'Get the vote url to vote our bot'
    })
    commands.create({
      name: 'info',
      description: 'Replies with all info of this bot'
    })

  });
  client.on('interactionCreate', async (interaction) => {
    if(!interaction.isCommand()){
      return
    }

    const { commandName, options } = interaction 

    if(commandName === 'help'){
      const user = interaction.options.getUser('target');
      const help = new MessageEmbed()
      .setColor('#111133')
      .setTitle("Truth Or Dare")
      .setURL('https://discord.com/api/oauth2/authorize?client_id=874488895037911041&permissions=259846043712&scope=bot')
      .addFields(
        { name: 'For Help', value: '```+help```' },
        { name: 'For Your Truth', value: '```+t```', inline: true },
        { name: 'For Your Dare', value: '```+d```', inline: true},
        { name: 'For Invite this bot on your server', value: '```+invite```' },
        { name: 'For Truth Questions Bangla', value:'```+tb```', inline: true},
        { name: 'For Dare Questions Bangla', value:'```+db```', inline: true},
        { name: 'For Vote Our Bot', value:'```+vote```'},
        { name: 'Created By', value: '<@723821826291138611> [**Leader at CODE HUNTER**]' },
      )
      .setDescription(
        `Truth Or Dare Bot Version: v${require("./package.json").version}
  [Website](https://web-truthordare.web.app/) | [Support Server](https://discord.gg/djhNPX2QUp) | By [Code Hunter](https://github.com/Code-Hunter-OfficialBD/)`
      )
      .setTimestamp()
      .setFooter(`${message.author.username} `, message.author.displayAvatarURL());
    interaction.reply({
      embeds: [help]
    })
    }
  })

and this is the error

.setFooter(`${message.author.username} `, message.author.displayAvatarURL());
                    ^

ReferenceError: message is not defined

now I don’t know what’s the matter but in my main prefix its works perfectly. in slash commands it’s sucks. What do I’ve to do??

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

I believe you are trying to reference message instead of interaction.
You are running that code in interactionCreate and named your parameter as interaction.

    const help = new MessageEmbed()
       // ...
      .setFooter(interaction.user.username, interaction.user.displayAvatarURL());
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading