#Embed is only sending once every time the slash command is ran every active session

13 messages · Page 1 of 1 (latest)

wet lance
#

By every active session I mean every time the bot is online.

I have a slash command that is like an 8ball command. It isnt finished since this is inly the testing version but It only sends the embed once then if I run it a 2nd time it says "Application didn't respond" with no errors in the console.

Here is my code:

client.once('interactionCreate', async (cmd) => {
    if (cmd.commandName === '8ball') {
        var finishedCheck = false;
        const randomInteger = randInt(0, 2)
        const embedBall = new EmbedBuilder()
        embedBall.setTitle('🎱 8ball')
        embedBall.setDescription('The 8ball has been rolled!')

        if(randomInteger == 0) {
            embedBall.addFields(
                {name: "8Ball's response", value: 'yes!'},
                

            )
        }
        if(randomInteger == 1) {
            embedBall.addFields(
                {name: "8Ball's response", value: 'no!'},
                

            )

        }
        if(randomInteger == 2) {
            embedBall.addFields(
                {name: "8Ball's response", value: 'maybe...'},
                

            )

        }
       
        await cmd.reply("The 8ball has spoken...")
        await cmd.channel.send({embeds: [embedBall]})
    
        

    }
})

I've tried: Resetting my bot's token, only using interaction.reply

Maybe it is because the command has an option that is being un used?

stark oysterBOT
#
  • What's your exact discord.js npm list discord.js and node node -v version?
  • Not a discord.js issue? Check out #1081585952654360687.
  • Consider reading #how-to-get-help to improve your question!
  • Explain what exactly your issue is.
  • Post the full error stack trace, not just the top part!
  • Show your code!
  • Issue solved? Press the button!
  • Marked as resolved by OP
chrome fern
#

You have client.once, which is for the event to only be emitted once

You should use client.on

wet lance
#

Also do you know why sometimes the "yes, no, maybe" section is sometimes left blank? I assume it is because the number hasnt generated in time. Maybe I can get around that with have a boolean that is set to true when the number is generated and then check iof the bool is true and if it is then send the embed?

chrome fern
#

The only thing i can think of, is that the randInt function isn't returning any of those values you check

wet lance
#

It sometimes returns "yes"

chrome fern
#

I'm talking about the function itself, it may be returning something that isn't 0, 1 nor 2

wet lance
chrome fern
#

No more issues then?

wet lance
#

Yep!

chrome fern
#

Alright 👍

wet lance
#

Thank you!