generated from nhcarrigan/template
feat: add button to clear reminder #3
@@ -47,8 +47,6 @@ client.on(Events.InteractionCreate, (interaction) => {
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle button clicks
|
||||
if (interaction.isButton()) {
|
||||
void handleAckButton(interaction);
|
||||
}
|
||||
|
||||
@@ -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!`,
|
||||
|
||||
@@ -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,
|
||||
|
naomi
commented
Unnecessary comment. Unnecessary comment.
|
||||
});
|
||||
setTimeout(() => {
|
||||
void interaction.deleteReply().catch(() => {
|
||||
// Intentionally empty - ignore deletion errors
|
||||
});
|
||||
}, 2000);
|
||||
return true;
|
||||
}
|
||||
|
||||
await interaction.message.delete();
|
||||
return true;
|
||||
|
naomi
commented
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.
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user
Unnecessary comment.