31 lines
830 B
TypeScript
31 lines
830 B
TypeScript
import { Client, Events, GatewayIntentBits } from 'discord.js';
|
|
import CommandService from './services/command';
|
|
|
|
const client = new Client({
|
|
intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent]
|
|
});
|
|
|
|
client.once(Events.ClientReady, async (readyClient) => {
|
|
// Initialize services
|
|
await CommandService.init();
|
|
|
|
console.log(`Ready! Logged in as ${readyClient.user.tag}`);
|
|
});
|
|
|
|
client.on("guildMemberAdd", async (guildMember) => {
|
|
});
|
|
|
|
client.on("messageCreate", async (message) => {
|
|
if (message.author.bot) return;
|
|
|
|
try {
|
|
const command = CommandService.parse(message);
|
|
if (command) await command.execute(message);
|
|
}
|
|
catch (err) {
|
|
console.error(err);
|
|
}
|
|
});
|
|
|
|
client.login(Bun.env.BOT_TOKEN);
|