1 |
import { Client, ClientOptions, Collection, Interaction, Message } from 'discord.js'; |
2 |
import BaseEvent from '../utils/structures/BaseEvent'; |
3 |
import BaseCommand from '../utils/structures/BaseCommand'; |
4 |
import { Config } from './Config'; |
5 |
import Database from './Database'; |
6 |
import path from 'path'; |
7 |
import Logger from '../automod/Logger'; |
8 |
import SpamFilter from '../automod/SpamFilter'; |
9 |
import SnippetManager from '../services/SnippetManager'; |
10 |
import AFKEngine from '../services/AFKEngine'; |
11 |
import Auth from '../services/Auth'; |
12 |
import MessageFilter from '../automod/MessageFilter'; |
13 |
import AntiRaid from '../automod/AntiRaid'; |
14 |
import Starboard from '../services/Starboard'; |
15 |
import Server from '../api/Server'; |
16 |
|
17 |
export default class DiscordClient extends Client { |
18 |
private _commands = new Collection<string, BaseCommand>(); |
19 |
private _events = new Collection<string, BaseEvent>(); |
20 |
|
21 |
rootdir: string; |
22 |
msg: Message | Interaction | null = null; |
23 |
|
24 |
config: Config; |
25 |
db: Database; |
26 |
logger: Logger; |
27 |
snippetManager: SnippetManager; |
28 |
afkEngine: AFKEngine; |
29 |
auth: Auth; |
30 |
spamFilter: SpamFilter; |
31 |
messageFilter: MessageFilter; |
32 |
antiraid: AntiRaid; |
33 |
starboard: Starboard; |
34 |
server: Server; |
35 |
|
36 |
static client: DiscordClient; |
37 |
|
38 |
constructor(options: ClientOptions, rootdir: string = __dirname) { |
39 |
super({ |
40 |
ws: { |
41 |
properties: { |
42 |
$browser: "Discord iOS" |
43 |
} |
44 |
}, |
45 |
...options |
46 |
}); |
47 |
|
48 |
this.rootdir = rootdir; |
49 |
|
50 |
this.config = new Config(this); |
51 |
this.db = new Database(path.resolve(rootdir, 'database.db'), this); |
52 |
this.logger = new Logger(this); |
53 |
this.snippetManager = new SnippetManager(this); |
54 |
this.afkEngine = new AFKEngine(this); |
55 |
this.auth = new Auth(this); |
56 |
this.spamFilter = new SpamFilter(this); |
57 |
this.messageFilter = new MessageFilter(this); |
58 |
this.antiraid = new AntiRaid(this); |
59 |
this.starboard = new Starboard(this); |
60 |
this.server = new Server(this); |
61 |
|
62 |
DiscordClient.client = this; |
63 |
} |
64 |
|
65 |
get commands(): Collection<string, BaseCommand> { |
66 |
return this._commands; |
67 |
} |
68 |
|
69 |
get events(): Collection<string, BaseEvent> { |
70 |
return this._events; |
71 |
} |
72 |
|
73 |
setMessage(msg: Message | Interaction) { |
74 |
this.msg = msg; |
75 |
} |
76 |
} |