generated from nhcarrigan/template
feat: add button to clear reminder #3
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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!`,
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
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,
|
||||||
});
|
});
|
||||||
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;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user