-
Notifications
You must be signed in to change notification settings - Fork 2
/
client.ts
29 lines (23 loc) · 900 Bytes
/
client.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* eslint-disable @typescript-eslint/no-var-requires */
import { Client, Collection } from 'discord.js';
import { Command } from 'interfaces';
import settings from 'settings';
import glob from 'glob';
import path from 'path';
export default class ExtendedClient extends Client {
public commands: Collection<string, Command> = new Collection();
public settings = settings;
public async init() {
this.login(this.settings['token']);
glob.sync('**/commands/**/**.public.ts').forEach((commandPath) => {
const { default: command } = require(path.join(__dirname, commandPath));
this.commands.set(command.data.name, command);
});
glob.sync('**/events/**/**.public.ts').forEach((eventPath) => {
const { default: event } = require(path.join(__dirname, eventPath));
this.on(event.name, (...args) => {
event.run(this, ...args);
});
});
}
}