Browse Source

Use a button instead of reaction for overriding answers

pull/41/head
Abheek Dhawan 3 years ago
parent
commit
13ebaa54bc
Signed by: abheekd GPG Key ID: 7BE81B8C14475B67
  1. 24
      src/commands/train.ts

24
src/commands/train.ts

@ -145,25 +145,31 @@ export async function execute(interaction) {
.setDescription('It seems your answer was incorrect. Please react with <:override:955265585086857236> to override your answer if you think you got it right.')
.setColor('#ffffff')
.setTimestamp();
const overrideButton = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId('override')
.setEmoji('<:override:955265585086857236>')
.setStyle('SECONDARY'),
);
answerMsg.channel.send({
embeds: [overrideEmbed],
components: [overrideButton],
})
.then(overrideMsg => {
overrideMsg.react('<:override:955265585086857236>');
const filter = (reaction, user) => {
const overrideFilter = i => {
return (
['override'].includes(reaction.emoji.name) &&
user.id === answerMsg.author.id
['override'].includes(i.customId) &&
i.user.id === answerMsg.author.id
);
};
overrideMsg
.awaitReactions({
filter: filter,
max: 1,
.awaitMessageComponent({
filter: overrideFilter,
})
.then(() => {
.then(i => {
updateScore(true, score, authorId).then((msgToReply) =>
answerMsg.reply(msgToReply),
i.reply(msgToReply),
);
}).catch(err => log({ logger: 'train', content: `Failed to override score: ${err}`, level: 'error' }));
}).catch(err => log({ logger: 'train', content: `Failed to send override message: ${err}`, level: 'error' }));

Loading…
Cancel
Save