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:
36
bot/prod/index.js
Normal file
36
bot/prod/index.js
Normal file
@ -0,0 +1,36 @@
|
||||
/**
|
||||
* @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);
|
Reference in New Issue
Block a user