discord.js v13 message is not defined?

Irtiza Khan Labib

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 it's 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 it works perfectly. in slash commands it's sucks. What do I've to do?

Palm

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());

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Discord.js V13 Welcome Message

Discord.js V13 sending message attachments

Discord.js v13 Return in Message Collector

Message collector not working discord js v13

message event updating discord.js from v12 to v13

Why am I getting a ReferenceError: AbortController is not defined in Discord.js v13?

How to send message to specified Channel - Discord.js v13 TypeScript

How can I get the second mention in a message discord.js v13

Discord.js (v13) - Edit a message using a dropdown menu

why is message.channel.awaitMessages() not working? | Discord.js V13

Is it possible to get more than one mentioned user from a message? | discord.js v13

How do I get the last message sent in a channel? | discord.js v13

Reply to author message after 1 hour in Discord.js v13

DiscordAPIError: Cannot send an empty message (discord.js v13)

Discord.js(v13) DiscordAPIError: Unknown Message when trying to do a word filter bot

Discord js v13 setChannel is undefined

Discord Bot Not Playing Audio discord.js v13

Interaction Channel messages (Discord.js v13)

Discord.js v13 (intermediate value).setToken(...) is not a function

Discord.js V13 array is not function

Discord js v13 channel filter not working

V13 Discord.JS Bot is not sending messages

Void.delete() (discord.JS v13)

Cannot send embed and components discord.js v13

How to filter the member counter in discord.js v13

setNickname is not including spaces in discord.js v13

Sending stickers in Discord.js V13

awaitMessages doesn't works in Discord.js v13

discord.js v13 member presence is undefined