From 1e8affd14a5161b069ba694727ba7138cb0861c4 Mon Sep 17 00:00:00 2001 From: Naomi Carrigan Date: Sun, 2 Nov 2025 09:17:53 -0800 Subject: [PATCH 1/5] Add acknowledgment button to alt-text reminders - Fixes #2 --- src/config/blocks.ts | 18 +++++++++++++++++ src/index.ts | 20 ++++++++++++++----- src/modules/checkAltText.ts | 4 +++- src/utils/buttonAck.ts | 40 +++++++++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+), 6 deletions(-) create mode 100644 src/utils/buttonAck.ts diff --git a/src/config/blocks.ts b/src/config/blocks.ts index 8a71c7f..1afa722 100644 --- a/src/config/blocks.ts +++ b/src/config/blocks.ts @@ -64,3 +64,21 @@ export const blocks = [ setURL("https://forum.nhcarrigan.com"), ), ]; + +// config for the acknowledgment button + +export const createAckButton = (userId: string) => { + const button = new ButtonBuilder() + .setCustomId(`ack-${userId}`) + .setLabel("Got it!") + .setStyle(ButtonStyle.Secondary) + .setEmoji("✅"); + + + const actionRow = new ActionRowBuilder() + .addComponents(button); + + return [actionRow]; + }; + +export const replyForUnauthorized = "❌ This button is only for the person who received the reminder."; \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index a41ee18..6b45884 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,6 +9,7 @@ import { Client, GatewayIntentBits, Events, MessageFlags } from "discord.js"; import { blocks } from "./config/blocks.js"; import { checkAltText } from "./modules/checkAltText.js"; import { instantiateServer } from "./server/serve.js"; +import { handleAckButton } from "./utils/buttonAck.js"; import { logger } from "./utils/logger.js"; const client = new Client({ @@ -35,13 +36,22 @@ client.on(Events.MessageCreate, (message) => { client.on(Events.InteractionCreate, (interaction) => { void analytics.logGatewayEvent(Events.InteractionCreate, { ...interaction }); - if (!interaction.isChatInputCommand()) { + if (!interaction.isChatInputCommand() && !interaction.isButton()) { return; } - void interaction.reply({ - components: blocks, - flags: MessageFlags.IsComponentsV2, - }); + // Existing logic for slash commands + if (interaction.isChatInputCommand()) { + void interaction.reply({ + components: blocks, + flags: MessageFlags.IsComponentsV2, + }); + return; + } + + // Handle button clicks + if (interaction.isButton()) { + void handleAckButton(interaction); + } }); await client.login(process.env.BOT_TOKEN); diff --git a/src/modules/checkAltText.ts b/src/modules/checkAltText.ts index 2883567..34bc288 100644 --- a/src/modules/checkAltText.ts +++ b/src/modules/checkAltText.ts @@ -5,6 +5,7 @@ */ import { reminders } from "../config/reminders.js"; +import { createAckButton } from "../utils/buttonAck.js"; import { getRandomValue } from "../utils/getRandomValue.js"; import { logger } from "../utils/logger.js"; import type { Message } from "discord.js"; @@ -33,7 +34,8 @@ export const checkAltText = async(message: Message): Promise => { if (noDescription.size > 0) { const reminder = getRandomValue(reminders); await message.reply({ - content: `${reminder}\n-# If you do not know how to do this, check [Discord's help article]()!\n-# Need help writing descriptive text? Our bot [Cordelia]() can do it for you!`, + components: createAckButton(message.author.id), + content: `${reminder}\n-# If you do not know how to do this, check [Discord's help article]()!\n-# Need help writing descriptive text? Our bot [Cordelia]() can do it for you!`, // Button for acknowledgment }).catch(() => { return null; }); diff --git a/src/utils/buttonAck.ts b/src/utils/buttonAck.ts new file mode 100644 index 0000000..8e6edb6 --- /dev/null +++ b/src/utils/buttonAck.ts @@ -0,0 +1,40 @@ +/** + * @copyright NHCarrigan + * @license Naomi's Public License + * @author Gurkirat Singh - Technical volunteer + */ + +import { ButtonInteraction, MessageFlags } from "discord.js"; +import { createAckButton as createAckButtonConfig } from "../config/blocks.js"; +import { replyForUnauthorized } from "../config/blocks.js"; + + + +/** + * Creates an acknowledgment button for alt-text reminders + * @param userId - The ID of the user who can acknowledge the reminder + * @returns ActionRow with the acknowledgment button + */ + + +export const createAckButton = (userId: string) => { + return createAckButtonConfig(userId); +}; + +// function to handle button interaction +export const handleAckButton = async (interaction: ButtonInteraction) => { + if (!interaction.customId.startsWith("ack-")) { + return false; // Not our button + } + + const authorizedUserId = interaction.customId.split("-")[1]; + if (interaction.user.id !== authorizedUserId) { + // Show error that auto-deletes after 2 seconds + await interaction.reply({ content: replyForUnauthorized, flags: MessageFlags.Ephemeral }); + setTimeout(() => interaction.deleteReply().catch(() => {}), 2000); + return true; + } + + await interaction.message.delete(); + return true; +} -- 2.52.0 From 22f741e585324155e644c3b2bcd1fc3bd5b39bb8 Mon Sep 17 00:00:00 2001 From: Naomi Carrigan Date: Sun, 2 Nov 2025 09:18:32 -0800 Subject: [PATCH 2/5] forgot to use lint --- src/config/blocks.ts | 39 +++++++++++++-------- src/modules/checkAltText.ts | 3 +- src/utils/buttonAck.ts | 68 +++++++++++++++++++++++-------------- 3 files changed, 68 insertions(+), 42 deletions(-) diff --git a/src/config/blocks.ts b/src/config/blocks.ts index 1afa722..e7c6bed 100644 --- a/src/config/blocks.ts +++ b/src/config/blocks.ts @@ -14,7 +14,7 @@ import { ActionRowBuilder, } from "discord.js"; -export const blocks = [ +const blocks = [ new ContainerBuilder(). addTextDisplayComponents( new TextDisplayBuilder().setContent("# About Altaria"), @@ -65,20 +65,29 @@ export const blocks = [ ), ]; -// config for the acknowledgment button +// Config for the acknowledgment button -export const createAckButton = (userId: string) => { - const button = new ButtonBuilder() - .setCustomId(`ack-${userId}`) - .setLabel("Got it!") - .setStyle(ButtonStyle.Secondary) - .setEmoji("✅"); +/** + * Creates an acknowledgment button for alt-text reminders. + * @param userId - The ID of the user who can acknowledge the reminder. + * @returns An array containing an ActionRow with the acknowledgment button. + */ +const createAckButton = ( + userId: string, +): Array> => { + const button = new ButtonBuilder(). + setCustomId(`ack-${userId}`). + setLabel("Got it!"). + setStyle(ButtonStyle.Secondary). + setEmoji("✅"); - - const actionRow = new ActionRowBuilder() - .addComponents(button); + const actionRow = new ActionRowBuilder(). + addComponents(button); - return [actionRow]; - }; - -export const replyForUnauthorized = "❌ This button is only for the person who received the reminder."; \ No newline at end of file + return [ actionRow ]; +}; + +const replyForUnauthorized + = "❌ This button is only for the person who received the reminder."; + +export { blocks, createAckButton, replyForUnauthorized }; diff --git a/src/modules/checkAltText.ts b/src/modules/checkAltText.ts index 34bc288..6054c3b 100644 --- a/src/modules/checkAltText.ts +++ b/src/modules/checkAltText.ts @@ -33,9 +33,10 @@ export const checkAltText = async(message: Message): Promise => { 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]()!\n-# Need help writing descriptive text? Our bot [Cordelia]() can do it for you!`, // Button for acknowledgment + content: `${reminder}\n-# If you do not know how to do this, check [Discord's help article]()!\n-# Need help writing descriptive text? Our bot [Cordelia]() can do it for you!`, }).catch(() => { return null; }); diff --git a/src/utils/buttonAck.ts b/src/utils/buttonAck.ts index 8e6edb6..6752af6 100644 --- a/src/utils/buttonAck.ts +++ b/src/utils/buttonAck.ts @@ -4,37 +4,53 @@ * @author Gurkirat Singh - Technical volunteer */ -import { ButtonInteraction, MessageFlags } from "discord.js"; -import { createAckButton as createAckButtonConfig } from "../config/blocks.js"; -import { replyForUnauthorized } from "../config/blocks.js"; - - +import { type ButtonInteraction, MessageFlags } from "discord.js"; +import { + createAckButton as createAckButtonConfig, + replyForUnauthorized, +} from "../config/blocks.js"; /** - * Creates an acknowledgment button for alt-text reminders - * @param userId - The ID of the user who can acknowledge the reminder - * @returns ActionRow with the acknowledgment button + * Creates an acknowledgment button for alt-text reminders. + * @param userId - The ID of the user who can acknowledge the reminder. + * @returns ActionRow with the acknowledgment button. */ - - -export const createAckButton = (userId: string) => { +const createAckButton = ( + userId: string, +): ReturnType => { return createAckButtonConfig(userId); }; -// function to handle button interaction -export const handleAckButton = async (interaction: ButtonInteraction) => { - if (!interaction.customId.startsWith("ack-")) { - return false; // Not our button - } - - const authorizedUserId = interaction.customId.split("-")[1]; - if (interaction.user.id !== authorizedUserId) { - // Show error that auto-deletes after 2 seconds - await interaction.reply({ content: replyForUnauthorized, flags: MessageFlags.Ephemeral }); - setTimeout(() => interaction.deleteReply().catch(() => {}), 2000); - return true; - } +/** + * Handles button interaction for acknowledgment buttons. + * @param interaction - The button interaction to handle. + * @returns Promise that resolves to true if the button was handled, false otherwise. + */ +const handleAckButton = async( + interaction: ButtonInteraction, +): Promise => { + if (!interaction.customId.startsWith("ack-")) { + // Not our button + return false; + } - await interaction.message.delete(); + const [ , authorizedUserId ] = interaction.customId.split("-"); + if (interaction.user.id !== authorizedUserId) { + // Show error that auto-deletes after 2 seconds + await interaction.reply({ + content: replyForUnauthorized, + flags: MessageFlags.Ephemeral, + }); + setTimeout(() => { + void interaction.deleteReply().catch(() => { + // Intentionally empty - ignore deletion errors + }); + }, 2000); return true; -} + } + + await interaction.message.delete(); + return true; +}; + +export { createAckButton, handleAckButton }; -- 2.52.0 From 429f4cf24f48c4643b567833906d0aa49724be3e Mon Sep 17 00:00:00 2001 From: GURKIRAT SINGH Date: Mon, 13 Oct 2025 02:58:14 +0530 Subject: [PATCH 3/5] made changes as requested by Naomi --- src/config/blocks.ts | 29 +--------------- src/index.ts | 2 +- src/modules/checkAltText.ts | 2 +- src/modules/createAckButton.ts | 33 +++++++++++++++++++ .../handleAckButton.ts} | 23 +++---------- 5 files changed, 40 insertions(+), 49 deletions(-) create mode 100644 src/modules/createAckButton.ts rename src/{utils/buttonAck.ts => modules/handleAckButton.ts} (57%) diff --git a/src/config/blocks.ts b/src/config/blocks.ts index e7c6bed..8a71c7f 100644 --- a/src/config/blocks.ts +++ b/src/config/blocks.ts @@ -14,7 +14,7 @@ import { ActionRowBuilder, } from "discord.js"; -const blocks = [ +export const blocks = [ new ContainerBuilder(). addTextDisplayComponents( new TextDisplayBuilder().setContent("# About Altaria"), @@ -64,30 +64,3 @@ const blocks = [ setURL("https://forum.nhcarrigan.com"), ), ]; - -// Config for the acknowledgment button - -/** - * Creates an acknowledgment button for alt-text reminders. - * @param userId - The ID of the user who can acknowledge the reminder. - * @returns An array containing an ActionRow with the acknowledgment button. - */ -const createAckButton = ( - userId: string, -): Array> => { - const button = new ButtonBuilder(). - setCustomId(`ack-${userId}`). - setLabel("Got it!"). - setStyle(ButtonStyle.Secondary). - setEmoji("✅"); - - const actionRow = new ActionRowBuilder(). - addComponents(button); - - return [ actionRow ]; -}; - -const replyForUnauthorized - = "❌ This button is only for the person who received the reminder."; - -export { blocks, createAckButton, replyForUnauthorized }; diff --git a/src/index.ts b/src/index.ts index 6b45884..2e64b6e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,8 +8,8 @@ import { DiscordAnalytics } from "@nhcarrigan/discord-analytics"; import { Client, GatewayIntentBits, Events, MessageFlags } from "discord.js"; import { blocks } from "./config/blocks.js"; import { checkAltText } from "./modules/checkAltText.js"; +import { handleAckButton } from "./modules/handleAckButton.js"; import { instantiateServer } from "./server/serve.js"; -import { handleAckButton } from "./utils/buttonAck.js"; import { logger } from "./utils/logger.js"; const client = new Client({ diff --git a/src/modules/checkAltText.ts b/src/modules/checkAltText.ts index 6054c3b..d58fdfc 100644 --- a/src/modules/checkAltText.ts +++ b/src/modules/checkAltText.ts @@ -5,7 +5,7 @@ */ import { reminders } from "../config/reminders.js"; -import { createAckButton } from "../utils/buttonAck.js"; +import { createAckButton } from "../modules/createAckButton.js"; import { getRandomValue } from "../utils/getRandomValue.js"; import { logger } from "../utils/logger.js"; import type { Message } from "discord.js"; diff --git a/src/modules/createAckButton.ts b/src/modules/createAckButton.ts new file mode 100644 index 0000000..3a99322 --- /dev/null +++ b/src/modules/createAckButton.ts @@ -0,0 +1,33 @@ +/** + * @copyright NHCarrigan + * @license Naomi's Public License + * @author Gurkirat Singh - Technical volunteer + */ + +import { + ActionRowBuilder, + ButtonBuilder, + ButtonStyle, +} from "discord.js"; + +/** + * Creates an acknowledgment button for alt-text reminders. + * @param userId - The ID of the user who can acknowledge the reminder. + * @returns An array containing an ActionRow with the acknowledgment button. + */ +const createAckButton = ( + userId: string, +): Array> => { + const button = new ButtonBuilder(). + setCustomId(`ack-${userId}`). + setLabel("Got it!"). + setStyle(ButtonStyle.Secondary). + setEmoji("✅"); + + const actionRow = new ActionRowBuilder(). + addComponents(button); + + return [ actionRow ]; +}; + +export { createAckButton }; diff --git a/src/utils/buttonAck.ts b/src/modules/handleAckButton.ts similarity index 57% rename from src/utils/buttonAck.ts rename to src/modules/handleAckButton.ts index 6752af6..b497f0e 100644 --- a/src/utils/buttonAck.ts +++ b/src/modules/handleAckButton.ts @@ -5,26 +5,11 @@ */ import { type ButtonInteraction, MessageFlags } from "discord.js"; -import { - createAckButton as createAckButtonConfig, - replyForUnauthorized, -} from "../config/blocks.js"; /** - * Creates an acknowledgment button for alt-text reminders. - * @param userId - The ID of the user who can acknowledge the reminder. - * @returns ActionRow with the acknowledgment button. - */ -const createAckButton = ( - userId: string, -): ReturnType => { - return createAckButtonConfig(userId); -}; - -/** - * Handles button interaction for acknowledgment buttons. + * Handles button interactions for acknowledgment buttons. * @param interaction - The button interaction to handle. - * @returns Promise that resolves to true if the button was handled, false otherwise. + * @returns Promise that resolves to true if button was handled, false otherwise. */ const handleAckButton = async( interaction: ButtonInteraction, @@ -38,7 +23,7 @@ const handleAckButton = async( if (interaction.user.id !== authorizedUserId) { // Show error that auto-deletes after 2 seconds await interaction.reply({ - content: replyForUnauthorized, + content: "❌ This button is only for the recipient.", flags: MessageFlags.Ephemeral, }); setTimeout(() => { @@ -53,4 +38,4 @@ const handleAckButton = async( return true; }; -export { createAckButton, handleAckButton }; +export { handleAckButton }; -- 2.52.0 From 0e52c1c6921346781e96264584262c7ab1efbedc Mon Sep 17 00:00:00 2001 From: Naomi Carrigan Date: Sun, 2 Nov 2025 09:18:47 -0800 Subject: [PATCH 4/5] fix: fixed the changes requested by naomi --- src/index.ts | 2 -- src/modules/checkAltText.ts | 1 - src/modules/handleAckButton.ts | 9 --------- 3 files changed, 12 deletions(-) diff --git a/src/index.ts b/src/index.ts index 2e64b6e..cede599 100644 --- a/src/index.ts +++ b/src/index.ts @@ -47,8 +47,6 @@ client.on(Events.InteractionCreate, (interaction) => { }); return; } - - // Handle button clicks if (interaction.isButton()) { void handleAckButton(interaction); } diff --git a/src/modules/checkAltText.ts b/src/modules/checkAltText.ts index d58fdfc..df34948 100644 --- a/src/modules/checkAltText.ts +++ b/src/modules/checkAltText.ts @@ -33,7 +33,6 @@ export const checkAltText = async(message: Message): Promise => { 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]()!\n-# Need help writing descriptive text? Our bot [Cordelia]() can do it for you!`, diff --git a/src/modules/handleAckButton.ts b/src/modules/handleAckButton.ts index b497f0e..bc89084 100644 --- a/src/modules/handleAckButton.ts +++ b/src/modules/handleAckButton.ts @@ -15,25 +15,16 @@ const handleAckButton = async( interaction: ButtonInteraction, ): Promise => { 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; }; -- 2.52.0 From 36e3a5370daf591fdd857a9802d654b47f162f91 Mon Sep 17 00:00:00 2001 From: Naomi Carrigan Date: Sun, 2 Nov 2025 09:22:20 -0800 Subject: [PATCH 5/5] chore: clean up code after review --- src/index.ts | 9 ++------ src/modules/checkAltText.ts | 17 ++++++++++++--- src/modules/createAckButton.ts | 33 ---------------------------- src/modules/handleAckButton.ts | 32 --------------------------- src/modules/processButton.ts | 40 ++++++++++++++++++++++++++++++++++ 5 files changed, 56 insertions(+), 75 deletions(-) delete mode 100644 src/modules/createAckButton.ts delete mode 100644 src/modules/handleAckButton.ts create mode 100644 src/modules/processButton.ts diff --git a/src/index.ts b/src/index.ts index cede599..9850b22 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,7 +8,7 @@ import { DiscordAnalytics } from "@nhcarrigan/discord-analytics"; import { Client, GatewayIntentBits, Events, MessageFlags } from "discord.js"; import { blocks } from "./config/blocks.js"; import { checkAltText } from "./modules/checkAltText.js"; -import { handleAckButton } from "./modules/handleAckButton.js"; +import { processButton } from "./modules/processButton.js"; import { instantiateServer } from "./server/serve.js"; import { logger } from "./utils/logger.js"; @@ -36,19 +36,14 @@ client.on(Events.MessageCreate, (message) => { client.on(Events.InteractionCreate, (interaction) => { void analytics.logGatewayEvent(Events.InteractionCreate, { ...interaction }); - if (!interaction.isChatInputCommand() && !interaction.isButton()) { - return; - } - // Existing logic for slash commands if (interaction.isChatInputCommand()) { void interaction.reply({ components: blocks, flags: MessageFlags.IsComponentsV2, }); - return; } if (interaction.isButton()) { - void handleAckButton(interaction); + void processButton(interaction); } }); diff --git a/src/modules/checkAltText.ts b/src/modules/checkAltText.ts index df34948..7e0ea23 100644 --- a/src/modules/checkAltText.ts +++ b/src/modules/checkAltText.ts @@ -5,7 +5,6 @@ */ import { reminders } from "../config/reminders.js"; -import { createAckButton } from "../modules/createAckButton.js"; import { getRandomValue } from "../utils/getRandomValue.js"; import { logger } from "../utils/logger.js"; import type { Message } from "discord.js"; @@ -34,8 +33,20 @@ export const checkAltText = async(message: Message): Promise => { if (noDescription.size > 0) { const reminder = getRandomValue(reminders); 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]()!\n-# Need help writing descriptive text? Our bot [Cordelia]() can do it for you!`, + components: [ { + components: [ + { + // eslint-disable-next-line @typescript-eslint/naming-convention -- Discord API requires this. + custom_id: message.author.id, + disabled: false, + label: "Okie Dokie!", + style: 3, + type: 2, + }, + ], + type: 1, + } ], + content: `${reminder}\n-# If you do not know how to do this, check [Discord's help article]()!\n-# Need help writing descriptive text? Our bot [Cordelia]() can do it for you!`, }).catch(() => { return null; }); diff --git a/src/modules/createAckButton.ts b/src/modules/createAckButton.ts deleted file mode 100644 index 3a99322..0000000 --- a/src/modules/createAckButton.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @copyright NHCarrigan - * @license Naomi's Public License - * @author Gurkirat Singh - Technical volunteer - */ - -import { - ActionRowBuilder, - ButtonBuilder, - ButtonStyle, -} from "discord.js"; - -/** - * Creates an acknowledgment button for alt-text reminders. - * @param userId - The ID of the user who can acknowledge the reminder. - * @returns An array containing an ActionRow with the acknowledgment button. - */ -const createAckButton = ( - userId: string, -): Array> => { - const button = new ButtonBuilder(). - setCustomId(`ack-${userId}`). - setLabel("Got it!"). - setStyle(ButtonStyle.Secondary). - setEmoji("✅"); - - const actionRow = new ActionRowBuilder(). - addComponents(button); - - return [ actionRow ]; -}; - -export { createAckButton }; diff --git a/src/modules/handleAckButton.ts b/src/modules/handleAckButton.ts deleted file mode 100644 index bc89084..0000000 --- a/src/modules/handleAckButton.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * @copyright NHCarrigan - * @license Naomi's Public License - * @author Gurkirat Singh - Technical volunteer - */ - -import { type ButtonInteraction, MessageFlags } from "discord.js"; - -/** - * Handles button interactions for acknowledgment buttons. - * @param interaction - The button interaction to handle. - * @returns Promise that resolves to true if button was handled, false otherwise. - */ -const handleAckButton = async( - interaction: ButtonInteraction, -): Promise => { - if (!interaction.customId.startsWith("ack-")) { - return false; - } - const [ , authorizedUserId ] = interaction.customId.split("-"); - if (interaction.user.id !== authorizedUserId) { - await interaction.reply({ - content: "❌ This button is only for the recipient.", - flags: MessageFlags.Ephemeral, - }); - return true; - } - await interaction.message.delete(); - return true; -}; - -export { handleAckButton }; diff --git a/src/modules/processButton.ts b/src/modules/processButton.ts new file mode 100644 index 0000000..e76eb23 --- /dev/null +++ b/src/modules/processButton.ts @@ -0,0 +1,40 @@ +/** + * @copyright NHCarrigan + * @license Naomi's Public License + * @author Naomi Carrigan + */ + +import { logger } from "../utils/logger.js"; +import type { + ButtonInteraction, +} from "discord.js"; + +/** + * Handles a button interaction. If the user is not the author of the reminder, + * they cannot acknowledge it. + * @param interaction - The interaction payload from Discord. + */ +export const processButton = async( + interaction: ButtonInteraction, +): Promise => { + try { + await interaction.deferReply({ ephemeral: true }); + const { customId, user, message } = interaction; + if (customId !== user.id) { + await interaction.editReply({ + content: "You cannot acknowledge someone else's reminder.", + }); + } + await message.delete(); + await interaction.editReply({ + content: "Acknowledged!", + }); + } catch (error) { + if (error instanceof Error) { + await logger.error("process interaction module", error); + } + await interaction.editReply({ + content: "Oh dear, something went wrong.", + }); + } +}; -- 2.52.0