Files
commands
config
events
utils
.gitignore
bot.ts
package.json
README.md
tsconfig.json
Code
14 627
bot.ts
import { Client, GatewayIntentBits, Partials } from 'discord.js';
import * as dotenv from 'dotenv';
import { handleReady } from './events/ready';
import { handleGuildMemberAdd } from './events/guildMemberAdd';
import { handleMessageReactionAdd } from './events/messageReactionAdd';
import { handleInteractionCreate } from './events/interactionCreate';
import { handleMessageCreate } from './events/messageCreate';
import { registerCommands } from './commands/registerCommands';
dotenv.config();
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.DirectMessageReactions,
GatewayIntentBits.MessageContent
],
partials: [
Partials.Message,
Partials.Channel,
Partials.Reaction,
Partials.User,
Partials.GuildMember
]
});
client.once('ready', async () => {
await handleReady(client);
if (client.user) {
await registerCommands(client.user.id);
}
});
client.on('guildMemberAdd', handleGuildMemberAdd);
client.on('messageReactionAdd', handleMessageReactionAdd);
client.on('interactionCreate', handleInteractionCreate);
client.on('messageCreate', handleMessageCreate);
process.on('unhandledRejection', (error) => {
console.error('❌ Неуправлявана грешка:', error);
});
client.login(process.env.DISCORD_TOKEN).catch((error) => {
console.error('❌ Грешка при влизане:', error);
process.exit(1);
});