generated from nhcarrigan/template
All checks were successful
Node.js CI / Lint and Test (pull_request) Successful in 1m17s
37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
/**
|
|
* @copyright nhcarrigan
|
|
* @license Naomi's Public License
|
|
* @author Naomi Carrigan
|
|
*/
|
|
import { Client, Events, GatewayIntentBits, Partials } from "discord.js";
|
|
import { chatInputInteractionCreate } from "./events/interactionCreate.js";
|
|
import { guildMessageCreate, directMessageCreate, } from "./events/messageCreate.js";
|
|
import { logger } from "./utils/logger.js";
|
|
const hikari = new Client({
|
|
intents: [
|
|
GatewayIntentBits.Guilds,
|
|
GatewayIntentBits.GuildMessages,
|
|
GatewayIntentBits.MessageContent,
|
|
GatewayIntentBits.DirectMessages,
|
|
],
|
|
partials: [
|
|
Partials.Channel,
|
|
],
|
|
});
|
|
hikari.once(Events.ClientReady, () => {
|
|
void logger.log("debug", `Logged in as ${hikari.user?.username ?? "unknown"}`);
|
|
});
|
|
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);
|
|
}
|
|
});
|
|
await hikari.login(process.env.DISCORD_TOKEN);
|