diff --git a/src/index.ts b/src/index.ts index b890f16..ea9f7ad 100644 --- a/src/index.ts +++ b/src/index.ts @@ -24,6 +24,7 @@ if (!config.token) { client.on('interactionCreate', async i => { if (i instanceof CommandInteraction) { + await i.deferReply(); switch (i.commandName) { case "poll": const rcp_polls = JSON.parse(fs.readFileSync('data/rcp_polls.json', "utf-8")); @@ -31,7 +32,7 @@ if (!config.token) { Object.keys(rcp_polls.approval.polls).forEach(poll => { polls += `:red_circle: **${rcp_polls.approval.polls[poll].pollster}** - (**${rcp_polls.approval.polls[poll].date}**), ${rcp_polls.approval.polls[poll].sample}, **${rcp_polls.approval.polls[poll].approve}**% approve, **${rcp_polls.approval.polls[poll].disapprove}**% disapprove (spread: **${rcp_polls.approval.polls[poll].spread}**)\n`; }); - await i.reply(`Biden Approval Rating\n\n${polls}`); + await i.editReply(`Biden Approval Rating\n\n${polls}`); break; case "simulate": var electionname = (i.options as CommandInteractionOptionResolver).getSubcommand(); @@ -56,11 +57,11 @@ if (!config.token) { var color = (i.options as CommandInteractionOptionResolver).getString("with_color") || "#bfab22"; var odds = (i.options as CommandInteractionOptionResolver).getNumber("with_odds") || 0.33; if (!/^#[0-9A-Fa-f]{3,6}$/.test(color)) { - await i.reply("Please provide a valid hex color code"); + await i.editReply("Please provide a valid hex color code"); return; } if (election.candidates.some(c => c.party === party || c.name === newcandidate)) { - await i.reply("A candidate with that name or party already exists"); + await i.editReply("A candidate with that name or party already exists"); return } election.candidates.push({ @@ -84,7 +85,7 @@ if (!config.token) { })) .setImage("attachment://election.png") .setTimestamp(); - await i.reply({embeds: [embed], files: [{attachment: result.png, name: "election.png"}]}); + await i.editReply({embeds: [embed], files: [{attachment: result.png, name: "election.png"}]}); } } });