20 |
import BaseCLICommand from '../utils/structures/BaseCLICommand'; |
import BaseCLICommand from '../utils/structures/BaseCLICommand'; |
21 |
import discordModals from 'discord-modals'; |
import discordModals from 'discord-modals'; |
22 |
import SpamFilter from '../automod/SpamFilter'; |
import SpamFilter from '../automod/SpamFilter'; |
23 |
|
import Verification from '../services/Verification'; |
24 |
|
import Welcomer from '../services/Welcomer'; |
25 |
|
import Antijoin from '../automod/Antijoin'; |
26 |
|
import Automute from '../automod/Automute'; |
27 |
|
import ServiceManager from './ServiceManager'; |
28 |
|
import ChannelLockManager from '../services/ChannelLockManager'; |
29 |
|
|
30 |
export default class DiscordClient extends Client { |
export default class DiscordClient extends Client { |
31 |
private _commands = new Collection<string, BaseCommand>(); |
private _commands = new Collection<string, BaseCommand>(); |
37 |
|
|
38 |
config: Config; |
config: Config; |
39 |
db: Database; |
db: Database; |
|
logger: Logger; |
|
|
snippetManager: SnippetManager; |
|
|
afkEngine: AFKEngine; |
|
|
auth: Auth; |
|
|
spamFilter: SpamFilter; |
|
|
messageFilter: MessageFilter; |
|
|
antiraid: AntiRaid; |
|
|
starboard: Starboard; |
|
40 |
server: Server; |
server: Server; |
41 |
cooldown: Cooldown; |
serviceManager: ServiceManager; |
42 |
startupManager: StartupManager; |
|
43 |
autoClear: AutoClear; |
logger: Logger = {} as Logger; |
44 |
randomStatus: RandomStatus; |
snippetManager: SnippetManager = {} as SnippetManager; |
45 |
debugLogger: DebugLogger; |
afkEngine: AFKEngine = {} as AFKEngine; |
46 |
|
auth: Auth = {} as Auth; |
47 |
|
spamFilter: SpamFilter = {} as SpamFilter; |
48 |
|
messageFilter: MessageFilter = {} as MessageFilter; |
49 |
|
antiraid: AntiRaid = {} as AntiRaid; |
50 |
|
starboard: Starboard = {} as Starboard; |
51 |
|
cooldown: Cooldown = {} as Cooldown; |
52 |
|
startupManager: StartupManager = {} as StartupManager; |
53 |
|
autoClear: AutoClear = {} as AutoClear; |
54 |
|
randomStatus: RandomStatus = {} as RandomStatus; |
55 |
|
debugLogger: DebugLogger = {} as DebugLogger; |
56 |
|
verification: Verification = {} as Verification; |
57 |
|
welcomer: Welcomer = {} as Welcomer; |
58 |
|
antijoin: Antijoin = {} as Antijoin; |
59 |
|
automute: Automute = {} as Automute; |
60 |
|
channelLock: ChannelLockManager = {} as ChannelLockManager; |
61 |
|
|
62 |
|
aliases = { |
63 |
|
automod: path.resolve(__dirname, '..', 'automod'), |
64 |
|
services: path.resolve(__dirname, '..', 'services'), |
65 |
|
}; |
66 |
|
|
67 |
|
services = { |
68 |
|
"@services/DebugLogger": "debugLogger", |
69 |
|
"@automod/Logger": "logger", |
70 |
|
"@services/SnippetManager": "snippetManager", |
71 |
|
"@services/AFKEngine": "afkEngine", |
72 |
|
"@services/Auth": "auth", |
73 |
|
"@automod/SpamFilter": "spamFilter", |
74 |
|
"@automod/MessageFilter": "messageFilter", |
75 |
|
"@automod/AntiRaid": "antiraid", |
76 |
|
"@services/Starboard": "starboard", |
77 |
|
"@automod/Cooldown": "cooldown", |
78 |
|
"@services/StartupManager": "startupManager", |
79 |
|
"@automod/AutoClear": "autoClear", |
80 |
|
"@services/RandomStatus": "randomStatus", |
81 |
|
"@services/Verification": "verification", |
82 |
|
"@services/Welcomer": "welcomer", |
83 |
|
"@services/ChannelLockManager": "channelLock", |
84 |
|
"@automod/Antijoin": "antijoin", |
85 |
|
"@automod/Automute": "automute", |
86 |
|
}; |
87 |
|
|
88 |
static client: DiscordClient; |
static client: DiscordClient; |
89 |
|
|
91 |
super({ |
super({ |
92 |
ws: { |
ws: { |
93 |
properties: { |
properties: { |
94 |
$browser: "Discord iOS" |
browser: "Discord iOS" |
95 |
} |
} |
96 |
}, |
}, |
97 |
...options |
...options |
98 |
}); |
}); |
99 |
|
|
100 |
|
process.on('uncaughtException', (error, origin) => { |
101 |
|
console.log('Uncaught', error); |
102 |
|
this.handleCrash(error, origin).then(() => process.exit(-1)).catch(err => { |
103 |
|
console.log(err); |
104 |
|
process.exit(-1); |
105 |
|
}); |
106 |
|
}); |
107 |
|
|
108 |
console.log('init'); |
console.log('init'); |
109 |
|
|
113 |
|
|
114 |
this.config = new Config(this); |
this.config = new Config(this); |
115 |
this.db = new Database(path.resolve(rootdir, 'database.db'), this); |
this.db = new Database(path.resolve(rootdir, 'database.db'), this); |
116 |
this.logger = new Logger(this); |
this.serviceManager = new ServiceManager(this, this.aliases); |
117 |
this.snippetManager = new SnippetManager(this); |
this.serviceManager.load(this.services); |
118 |
this.afkEngine = new AFKEngine(this); |
|
119 |
this.auth = new Auth(this); |
// this.logger = new Logger(this); |
120 |
this.spamFilter = new SpamFilter(this); |
// this.snippetManager = new SnippetManager(this); |
121 |
this.messageFilter = new MessageFilter(this); |
// this.afkEngine = new AFKEngine(this); |
122 |
this.antiraid = new AntiRaid(this); |
// this.auth = new Auth(this); |
123 |
this.starboard = new Starboard(this); |
// this.spamFilter = new SpamFilter(this); |
124 |
|
// this.messageFilter = new MessageFilter(this); |
125 |
|
// this.antiraid = new AntiRaid(this); |
126 |
|
// this.starboard = new Starboard(this); |
127 |
|
// this.cooldown = new Cooldown(this); |
128 |
|
// this.startupManager = new StartupManager(this); |
129 |
|
// this.autoClear = new AutoClear(this); |
130 |
|
// this.randomStatus = new RandomStatus(this); |
131 |
|
// this.debugLogger = new DebugLogger(this); |
132 |
|
// this.verification = new Verification(this); |
133 |
|
// this.welcomer = new Welcomer(this); |
134 |
|
// this.antijoin = new Antijoin(this); |
135 |
|
// this.automute = new Automute(this); |
136 |
|
|
137 |
this.server = new Server(this); |
this.server = new Server(this); |
|
this.cooldown = new Cooldown(this); |
|
|
this.startupManager = new StartupManager(this); |
|
|
this.autoClear = new AutoClear(this); |
|
|
this.randomStatus = new RandomStatus(this); |
|
|
this.debugLogger = new DebugLogger(this); |
|
138 |
|
|
139 |
discordModals(this); |
discordModals(this); |
140 |
} |
} |
154 |
setMessage(msg: Message | Interaction) { |
setMessage(msg: Message | Interaction) { |
155 |
this.msg = msg; |
this.msg = msg; |
156 |
} |
} |
157 |
|
|
158 |
|
async handleCrash(error: Error, origin: NodeJS.UncaughtExceptionOrigin) { |
159 |
|
console.log('here'); |
160 |
|
await this.debugLogger.logToHomeServer(`Uncaught ${error.name}: ${error.message}\n${error.stack}`); |
161 |
|
} |
162 |
} |
} |