Restructure bot

This commit is contained in:
Dominic Ferrando
2026-09-26 21:06:06 -04:00
parent db206bafa3
commit 7f791babd4
5 changed files with 51 additions and 48 deletions
+10 -12
View File
@@ -1,20 +1,13 @@
import { Client, Events, GatewayIntentBits } from 'discord.js';
import { CommandService } from './services/cmd/service';
import CommandService from './services/command';
const client = new Client({
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent]
});
// SERVICES
// -----------------------
const s = (() => {
const Commands = new CommandService(client);
return { Commands };
})();
client.once(Events.ClientReady, async (readyClient) => {
// Initialize
await s.Commands.init();
// Initialize services
await CommandService.init();
console.log(`Ready! Logged in as ${readyClient.user.tag}`);
});
@@ -25,8 +18,13 @@ client.on("guildMemberAdd", async (guildMember) => {
client.on("messageCreate", async (message) => {
if (message.author.bot) return;
const command = s.Commands.parse(message);
if (command) command.execute(message);
try {
const command = CommandService.parse(message);
if (command) await command.execute(message);
}
catch (err) {
console.error(err);
}
});
client.login(Bun.env.BOT_TOKEN);