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

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]})



}
})
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?
13 Replies
d.js toolkit
d.js toolkit11mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - 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
AlexCdDg
AlexCdDg11mo ago
You have client.once, which is for the event to only be emitted once You should use client.on
thatitalianguy
thatitalianguyOP11mo ago
My copilot plugin adds stuff onto my code sometimes. Thank you for pointing that out!
thatitalianguy
thatitalianguyOP11mo ago
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?
No description
AlexCdDg
AlexCdDg11mo ago
The only thing i can think of, is that the randInt function isn't returning any of those values you check
thatitalianguy
thatitalianguyOP11mo ago
It sometimes returns "yes"
AlexCdDg
AlexCdDg11mo ago
I'm talking about the function itself, it may be returning something that isn't 0, 1 nor 2
thatitalianguy
thatitalianguyOP11mo ago
the fix was adding a check AND updating the function. My subtraction was the opposite way around.
AlexCdDg
AlexCdDg11mo ago
No more issues then?
thatitalianguy
thatitalianguyOP11mo ago
Yep!
AlexCdDg
AlexCdDg11mo ago
Alright 👍
thatitalianguy
thatitalianguyOP11mo ago
Thank you!
AlexCdDg
AlexCdDg11mo ago
No problem 😄, you can mark the thread as solved here
Want results from more Discord servers?
Add your server