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: [] });
}


},
};
Was this page helpful?