Files
keiko/src/modules/dm.ts
T
naomi 68f7eabe2c
Code Analysis / SonarQube (push) Failing after 19s
Node.js CI / Lint and Test (push) Has been cancelled
feat: initial prototype
2025-10-09 11:28:47 -07:00

40 lines
1.1 KiB
TypeScript

/**
* @copyright nhcarrigan
* @license Naomi's Public License
* @author Naomi Carrigan
*/
import { MessageFlags, type ChatInputCommandInteraction } from "discord.js";
import { isNaomiInteraction } from "../utils/isNaomi.js";
import { logger } from "../utils/logger.js";
import { replyToError } from "../utils/replyToError.js";
/**
* Sends a DM to start a conversation in case the DM channel is lost.
* @param interaction -- The interaction payload from Discord.
*/
export const dm = async(
interaction: ChatInputCommandInteraction,
): Promise<void> => {
try {
await interaction.deferReply({ flags: [ MessageFlags.Ephemeral ] });
const isNaomi = await isNaomiInteraction(interaction);
if (!isNaomi) {
return;
}
await interaction.user.send(
"Hello Naomi. How may I serve you today?",
);
await interaction.reply({
content: "I've sent you a DM!",
ephemeral: true,
});
} catch (error) {
await replyToError(interaction);
if (error instanceof Error) {
await logger.error("about command", error);
}
}
};