generated from nhcarrigan/template
feat: build out discord support agent
All checks were successful
Node.js CI / Lint and Test (pull_request) Successful in 1m17s
All checks were successful
Node.js CI / Lint and Test (pull_request) Successful in 1m17s
This commit is contained in:
29
bot/prod/events/interactionCreate.js
Normal file
29
bot/prod/events/interactionCreate.js
Normal file
@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @copyright nhcarrigan
|
||||
* @license Naomi's Public License
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
import { about } from "../commands/about.js";
|
||||
import { dm } from "../commands/dm.js";
|
||||
const handlers = {
|
||||
_default: async (_, interaction) => {
|
||||
await interaction.reply({
|
||||
content: `Unknown command: ${interaction.commandName}`,
|
||||
ephemeral: true,
|
||||
});
|
||||
},
|
||||
about: about,
|
||||
dm: dm,
|
||||
};
|
||||
/**
|
||||
* Processes a slash command.
|
||||
* @param hikari - Hikari's Discord instance.
|
||||
* @param interaction - The command interaction payload from Discord.
|
||||
*/
|
||||
const chatInputInteractionCreate = async (hikari, interaction) => {
|
||||
const name = interaction.commandName;
|
||||
// eslint-disable-next-line no-underscore-dangle -- We use _default as a fallback handler.
|
||||
const handler = handlers[name] ?? handlers._default;
|
||||
await handler(hikari, interaction);
|
||||
};
|
||||
export { chatInputInteractionCreate };
|
Reference in New Issue
Block a user