mirror of
https://github.com/ahmadk953/poixpixel-discord-bot.git
synced 2025-05-10 10:43:06 +00:00
Added Warn and Ban Commands, Added Logging, and Much More
This commit is contained in:
parent
d89de72e08
commit
86adac3f08
33 changed files with 2200 additions and 204 deletions
45
src/structures/ExtendedClient.ts
Normal file
45
src/structures/ExtendedClient.ts
Normal file
|
@ -0,0 +1,45 @@
|
|||
import { Client, ClientOptions, Collection } from 'discord.js';
|
||||
import { Command } from '../types/CommandTypes.js';
|
||||
import { Config } from '../types/ConfigTypes.js';
|
||||
import { deployCommands } from '../util/deployCommand.js';
|
||||
import { registerEvents } from '../util/eventLoader.js';
|
||||
|
||||
export class ExtendedClient extends Client {
|
||||
public commands: Collection<string, Command>;
|
||||
private config: Config;
|
||||
|
||||
constructor(options: ClientOptions, config: Config) {
|
||||
super(options);
|
||||
this.commands = new Collection();
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
async initialize() {
|
||||
try {
|
||||
await this.loadModules();
|
||||
await this.login(this.config.token);
|
||||
} catch (error) {
|
||||
console.error('Failed to initialize client:', error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
private async loadModules() {
|
||||
try {
|
||||
const commands = await deployCommands();
|
||||
if (!commands?.length) {
|
||||
throw new Error('No commands found');
|
||||
}
|
||||
|
||||
for (const command of commands) {
|
||||
this.commands.set(command.data.name, command);
|
||||
}
|
||||
|
||||
await registerEvents(this);
|
||||
console.log(`Loaded ${commands.length} commands and registered events`);
|
||||
} catch (error) {
|
||||
console.error('Error loading modules:', error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue