-
Notifications
You must be signed in to change notification settings - Fork 0
/
commandError.ts
28 lines (22 loc) · 1.04 KB
/
commandError.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
import { APIMessageContentResolvable, MessageAdditions, MessageEmbed, MessageOptions } from 'discord.js';
import { Color } from './color';
export class CommandError extends Error {
public constructor(public readonly content: APIMessageContentResolvable | (MessageOptions & { split?: false }) | MessageAdditions) {
super();
}
private static error(prefix: string, commandName: string, message: string): CommandError {
return new CommandError(new MessageEmbed()
.setColor(Color.red)
.setTitle(commandName)
.setDescription(`${prefix}: ${message}`));
}
public static syntax(commandName: string, message: string): CommandError {
return this.error('SyntaxError', commandName, message);
}
public static semantic(commandName: string, message: string): CommandError {
return this.error('SemanticError', commandName, message);
}
public static generic(commandName: string, message: string): CommandError {
return this.error('Error', commandName, message);
}
}