Skip to content

Commit

Permalink
Fix the button deferral
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremy-rifkin committed Jan 6, 2024
1 parent 5f697aa commit 4beef28
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/components/the-button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,18 +192,19 @@ export default class TheButton extends BotComponent {
return;
}
// it might take a moment to go through everything
await interaction.deferReply();
await interaction.deferReply({
ephemeral: true,
});
// add user to the scoreboard if needed
const entry = await this.wheatley.database.button_scoreboard.findOne({ user: interaction.user.id });
// check to see if the user has pressed it within the last 24 hours
if (entry && Date.now() - entry.last_press <= PRESS_TIMEOUT) {
// ~~x converts the float x to an integer
// next_possible is the unix-time for the next possible button press
const next_possible = ~~((entry.last_press + PRESS_TIMEOUT) / 1000);
await interaction.reply({
await interaction.editReply({
// string highlighting is screwed, because of the '<' and '>' characters
content: `You can press the button again <t:${next_possible}:R>`,
ephemeral: true,
});
return;
}
Expand Down Expand Up @@ -246,7 +247,7 @@ export default class TheButton extends BotComponent {
const scoreboard_index = await this.wheatley.database.button_scoreboard.countDocuments({
score: { $gt: res.score },
});
await interaction.reply({
await interaction.editReply({
embeds: [
new Discord.EmbedBuilder()
.setDescription(
Expand All @@ -256,7 +257,6 @@ export default class TheButton extends BotComponent {
)
.setColor(colors.wheatley),
],
ephemeral: true,
});
await this.update_metadata();
}
Expand Down

0 comments on commit 4beef28

Please sign in to comment.