feat: add button to clear reminder #3

Merged
naomi merged 5 commits from Add-button-to-clear-reminder-#2 into main 2025-11-02 09:23:30 -08:00
3 changed files with 0 additions and 12 deletions
Showing only changes of commit 0e52c1c692 - Show all commits
-2
View File
1
@@ -47,8 +47,6 @@ client.on(Events.InteractionCreate, (interaction) => {
}); });
return; return;
} }
// Handle button clicks
if (interaction.isButton()) { if (interaction.isButton()) {
void handleAckButton(interaction); void handleAckButton(interaction);
} }
-1
View File
1
@@ -33,7 +33,6 @@ export const checkAltText = async(message: Message): Promise<void> => {
if (noDescription.size > 0) { if (noDescription.size > 0) {
const reminder = getRandomValue(reminders); const reminder = getRandomValue(reminders);
// Button for acknowledgment
await message.reply({ await message.reply({
components: createAckButton(message.author.id), components: createAckButton(message.author.id),
content: `${reminder}\n-# If you do not know how to do this, check [Discord's help article](<https://support.discord.com/hc/en-us/articles/211866427-How-do-I-upload-images-and-GIFs>)!\n-# Need help writing descriptive text? Our bot [Cordelia](<https://cordelia.nhcarrigan.com>) can do it for you!`, content: `${reminder}\n-# If you do not know how to do this, check [Discord's help article](<https://support.discord.com/hc/en-us/articles/211866427-How-do-I-upload-images-and-GIFs>)!\n-# Need help writing descriptive text? Our bot [Cordelia](<https://cordelia.nhcarrigan.com>) can do it for you!`,
-9
View File
@@ -15,25 +15,16 @@ const handleAckButton = async(
interaction: ButtonInteraction, interaction: ButtonInteraction,
): Promise<boolean> => { ): Promise<boolean> => {
if (!interaction.customId.startsWith("ack-")) { if (!interaction.customId.startsWith("ack-")) {
// Not our button
return false; return false;
Outdated
Review

Unnecessary comment.

Unnecessary comment.
} }
const [ , authorizedUserId ] = interaction.customId.split("-"); const [ , authorizedUserId ] = interaction.customId.split("-");
if (interaction.user.id !== authorizedUserId) { if (interaction.user.id !== authorizedUserId) {
// Show error that auto-deletes after 2 seconds
await interaction.reply({ await interaction.reply({
content: "❌ This button is only for the recipient.", content: "❌ This button is only for the recipient.",
flags: MessageFlags.Ephemeral, flags: MessageFlags.Ephemeral,
Outdated
Review

Unnecessary comment.

Unnecessary comment.
}); });
setTimeout(() => {
void interaction.deleteReply().catch(() => {
// Intentionally empty - ignore deletion errors
});
}, 2000);
return true; return true;
} }
await interaction.message.delete(); await interaction.message.delete();
return true; return true;
Outdated
Review

Skip this entirely. We don't need to auto-delete an ephemeral message.

Skip this entirely. We don't need to auto-delete an ephemeral message.
}; };