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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
import { BushCommand, BushMessage, BushSlashMessage } from '@lib';
export default class ReloadCommand extends BushCommand {
public constructor() {
super('reload', {
aliases: ['reload'],
category: 'dev',
description: {
content: 'Reloads the bot',
usage: ['reload'],
examples: ['reload']
},
// args: [
// {
// id: 'fast',
// match: 'flag',
// flag: '--fast'
// }
// ],
ownerOnly: true,
typing: true,
slash: true,
// slashOptions: [
// {
// name: 'fast',
// description: 'Whether to use esbuild for fast compiling or not',
// type: 'BOOLEAN',
// required: false
// }
// ],
clientPermissions: (m) => util.clientSendAndPermCheck(m),
userPermissions: []
});
}
public override async exec(message: BushMessage | BushSlashMessage /* { fast }: { fast: boolean } */) {
if (!message.author.isOwner())
return await message.util.reply(`${util.emojis.error} Only my developers can run this command.`);
let output: { stdout: string; stderr: string };
try {
const s = new Date();
output = await util.shell(`yarn build-${/* fast ? 'esbuild' : */ 'tsc'}`);
await Promise.all([
client.commandHandler.reloadAll(),
client.listenerHandler.reloadAll(),
client.inhibitorHandler.reloadAll(),
client.contextMenuCommandHandler.reloadAll(),
client.taskHandler.reloadAll()
]);
return message.util.send(`🔁 Successfully reloaded! (${new Date().getTime() - s.getTime()}ms)`);
} catch (e) {
if (output!) void client.logger.error('reloadCommand', output);
return message.util.send(
`An error occurred while reloading:\n${await util.codeblock(e?.stack || e, 2048 - 34, 'js', true)}`
);
}
}
}
|