CalcWarrior
CalcWarrior
Explore posts from servers
DIAdiscord.js - Imagine an app
Created by CalcWarrior on 10/4/2023 in #djs-questions
"Interaction has already been acknowledged." discord.js bot
So my bot has been giving me this error where it either says "Interaction has already been acknowledged" or "Unknown interaction" - in both cases, I know my slash command file exists and should be working. How do I fix these two cases?
7 replies
DIAdiscord.js - Imagine an app
Created by CalcWarrior on 5/3/2023 in #djs-questions
how to connect discord to localhost
I am trying to connect my score data to localhost and i am not sure what code i would use to send.
8 replies
DIAdiscord.js - Imagine an app
Created by CalcWarrior on 5/3/2023 in #djs-questions
buttons not working
Hi! I have a code that should give a sample math test - it gives you a linear equation and two answer choices (one of them is correct) The code is pasted below: const { ActionRowBuilder, ButtonBuilder, ButtonStyle, SlashCommandBuilder } = require('discord.js'); module.exports = { data: new SlashCommandBuilder() .setName('mathtest') .setDescription('Gives you a math test'), async execute(interaction) { var a = Math.floor(Math.random()10)+1; var b = Math.floor(Math.random()10)+1; var c = Math.floor(Math.random()(20-(a+b)))+a+b; var d = Math.floor(Math.random())+1; var aone; var atwo; var sol; if(d === 1){ aone = (c - b)/a; atwo = Math.floor(Math.random()10)+1; sol = aone; } if(d === 2){ aone = Math.floor(Math.random()*10)+1; atwo = (c-b)/a; sol = atwo; } const answerone = new ButtonBuilder() .setCustomId('answerone') .setLabel(${aone}) .setStyle(ButtonStyle.Primary); const answertwo = new ButtonBuilder() .setCustomId('answertwo') .setLabel(${atwo}) .setStyle(ButtonStyle.Primary); const row = new ActionRowBuilder() .addComponents(answerone, answertwo);
const response = await interaction.reply({ content: Solve the math problem, ${a}x + ${b} = ${c}, components: [row], });
const collectorFilter = i => i.user.id === interaction.user.id; try { const answer = await response.awaitMessageComponent({ filter: collectorFilter, time: 60_000 });
if (answer.Label === ${sol}) { await answer.update({ content: Sorry, incorrect, components: [] }); } else if (answer.Label !== ${sol}) { await answer.update({ content: 'You got it correct!', components: [] }); } } catch (e) { await response.editReply({ content: 'Nobody answered!', components: [] }); }
}, };
79 replies