feat: add button to acknowledge reminders
Node.js CI / Lint and Test (push) Successful in 40s

This commit is contained in:
2025-11-02 09:13:04 -08:00
parent d5d419b06c
commit a915f50f1a
3 changed files with 61 additions and 3 deletions
+47
View File
@@ -0,0 +1,47 @@
/**
* @copyright NHCarrigan
* @license Naomi's Public License
* @author Naomi Carrigan
*/
import { logger } from "../utils/logger.js";
import type {
ButtonInteraction,
} from "discord.js";
/**
* Handles a slash command. Only responds with the about information,
* because that's all we need.
* @param interaction - The interaction payload from Discord.
*/
/**
* 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<void> => {
try {
await interaction.deferReply();
const { customId, user, message } = interaction;
if (customId !== user.id) {
await interaction.reply({
content: "You cannot acknowledge someone else's reminder.",
ephemeral: true,
});
}
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.",
});
}
};