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
@@ -47,8 +47,6 @@ client.on(Events.InteractionCreate, (interaction) => {
});
return;
}
// Handle button clicks
if (interaction.isButton()) {
void handleAckButton(interaction);
}
-1
View File
@@ -33,7 +33,6 @@ export const checkAltText = async(message: Message): Promise<void> => {
if (noDescription.size > 0) {
const reminder = getRandomValue(reminders);
// Button for acknowledgment
await message.reply({
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!`,
-9
View File
@@ -15,25 +15,16 @@ const handleAckButton = async(
interaction: ButtonInteraction,
): Promise<boolean> => {
if (!interaction.customId.startsWith("ack-")) {
// Not our button
return false;
}
const [ , authorizedUserId ] = interaction.customId.split("-");
if (interaction.user.id !== authorizedUserId) {
// Show error that auto-deletes after 2 seconds
await interaction.reply({
content: "❌ This button is only for the recipient.",
flags: MessageFlags.Ephemeral,
});
setTimeout(() => {
void interaction.deleteReply().catch(() => {
// Intentionally empty - ignore deletion errors
});
}, 2000);
return true;
}
await interaction.message.delete();
return true;
};