-
Notifications
You must be signed in to change notification settings - Fork 1
/
command.ts
46 lines (41 loc) · 884 Bytes
/
command.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
interface Command {
data: {
name: string;
description: string;
category: string;
arguments: string[];
};
execute: (
context,
client,
commands,
EmbedBuilder,
database
) => Promise<void>;
}
// Commands
if (!message.content.startsWith(process.env.PREFIX || ".")) return;
const args = message.content
.slice((process.env.PREFIX || ".").length)
.split(/ +/);
const commandName = args.shift()?.toLowerCase();
const command = commands.get(commandName);
if (!command) return;
try {
const context = {
message: message,
arguments: args,
};
await command.execute(
context,
client,
commands,
EmbedBuilder,
database
);
} catch (error) {
logger.error(`Command (${commandName})`, error);
message.reply(
`I just became a failure, hold up.\n\n${codeBlock("js", error)}`
);
}