Files
hikari/bot/src/index.ts
T
hikari 11b23b10a6
Node.js CI / CI (push) Successful in 41s
Security Scan and Upload / Security & DefectDojo Upload (push) Successful in 1m56s
refactor: consolidate modal routing and use LabelBuilder for modal components
Merges modalInteractionCreate into interactionCreate, and replaces
ActionRowBuilder with LabelBuilder for the announcement modal components.
2026-03-12 23:21:06 -07:00

65 lines
1.4 KiB
TypeScript

/**
* @copyright nhcarrigan
* @license Naomi's Public License
* @author Naomi Carrigan
*/
import { DiscordAnalytics } from "@nhcarrigan/discord-analytics";
import { Client, Events, GatewayIntentBits, Partials } from "discord.js";
import {
chatInputInteractionCreate,
modalSubmitInteractionCreate,
} from "./events/interactionCreate.js";
import { logger } from "./utils/logger.js";
/*
* Import {
* guildMessageCreate,
* directMessageCreate,
* } from "./events/messageCreate.js";
*/
const hikari = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.DirectMessages,
],
partials: [
Partials.Channel,
],
});
const analytics = new DiscordAnalytics(hikari, logger);
hikari.once(Events.ClientReady, () => {
void logger.log(
"debug",
`Logged in as ${hikari.user?.username ?? "unknown"}`,
);
analytics.startCron();
});
/*
* Hikari.on(Events.MessageCreate, (message) => {
* if (!message.inGuild()) {
* void directMessageCreate(hikari, message);
* return;
* }
* void guildMessageCreate(hikari, message);
* });
*/
hikari.on(Events.InteractionCreate, (interaction) => {
if (interaction.isChatInputCommand()) {
void chatInputInteractionCreate(hikari, interaction);
return;
}
if (interaction.isModalSubmit()) {
void modalSubmitInteractionCreate(hikari, interaction);
}
});
await hikari.login(process.env.DISCORD_TOKEN);