feat: add a slash command so we can be discoverable
Node.js CI / Lint and Test (push) Failing after 38s

This commit is contained in:
2025-08-22 14:52:41 -07:00
parent 74605cc219
commit dde62d4171
3 changed files with 98 additions and 1 deletions
+8
View File
@@ -9,6 +9,7 @@ import {
GatewayIntentBits,
Events,
} from "discord.js";
import { processInteraction } from "./modules/processInteraction.js";
import { processMessage } from "./modules/processMessage.js";
import { instantiateServer } from "./server/serve.js";
import { logger } from "./utils/logger.js";
@@ -29,5 +30,12 @@ caelia.on(Events.MessageCreate, (message) => {
void processMessage(message);
});
caelia.on(Events.InteractionCreate, (interaction) => {
if (!interaction.isChatInputCommand()) {
return;
}
void processInteraction(interaction);
});
await caelia.login(process.env.BOT_TOKEN);
instantiateServer();
+88
View File
@@ -0,0 +1,88 @@
/**
* @copyright NHCarrigan
* @license Naomi's Public License
* @author Naomi Carrigan
*/
import {
type ChatInputCommandInteraction,
ContainerBuilder,
TextDisplayBuilder,
SeparatorBuilder,
SeparatorSpacingSize,
ButtonBuilder,
ButtonStyle,
ActionRowBuilder,
MessageFlags,
} from "discord.js";
import { logger } from "../utils/logger.js";
/**
* Handles a slash command. Only responds with the about information,
* because that's all we need.
* @param interaction - The interaction payload from Discord.
*/
// eslint-disable-next-line max-lines-per-function -- Mostly components.
export const processInteraction = async(
interaction: ChatInputCommandInteraction,
): Promise<void> => {
try {
const components = [
new ContainerBuilder().
addTextDisplayComponents(
new TextDisplayBuilder().setContent("# About Caelia"),
).
addTextDisplayComponents(
new TextDisplayBuilder().setContent(
// eslint-disable-next-line stylistic/max-len -- Big boi string.
"Hi there~! I am Caelia, a bot that gives you gentle reminders when you use language that is not inclusive.",
),
).
addSeparatorComponents(
new SeparatorBuilder().
setSpacing(SeparatorSpacingSize.Small).
setDivider(true),
).
addTextDisplayComponents(
new TextDisplayBuilder().setContent("## What can I do?"),
).
addTextDisplayComponents(
new TextDisplayBuilder().setContent(
// eslint-disable-next-line stylistic/max-len -- Big boi string.
"This is super duper quick! All you need to do is add me to your server, give me access to see messages and respond in channels you want me to monitor, and I will take care of the rest~!",
),
).
addSeparatorComponents(
new SeparatorBuilder().
setSpacing(SeparatorSpacingSize.Small).
setDivider(true),
).
addTextDisplayComponents(
new TextDisplayBuilder().setContent("## What if I need help?"),
).
addTextDisplayComponents(
new TextDisplayBuilder().setContent(
// eslint-disable-next-line stylistic/max-len -- Big boi string.
"My deepest apologies if I have made a mistake! Please reach out to us in our Discord server and we will do our best to assist you.",
),
),
new ActionRowBuilder<ButtonBuilder>().addComponents(
new ButtonBuilder().
setStyle(ButtonStyle.Link).
setLabel("Discord Server").
setURL("https://chat.nhcarrigan.com"),
),
];
await interaction.reply({
components: components,
flags: MessageFlags.IsComponentsV2,
});
} catch (error) {
if (error instanceof Error) {
await logger.error("process interaction module", error);
}
await interaction.editReply({
content: "Oh dear, something went wrong.",
});
}
};
+2 -1
View File
@@ -39,7 +39,8 @@ export const processMessage = async(message: Message): Promise<void> => {
? match.reason
: "I said so."}${[ null, "", undefined, "undefined", "null" ].includes(match.note)
? ""
: ` -- ${match.note}`}`;
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- Fuck off
: ` -- ${match.note!}`}`;
});
await message.reply({ components: [