Files

28 lines
1.0 KiB
TypeScript
Raw Permalink Normal View History

2021-05-13 16:18:31 +02:00
import { APIMessageContentResolvable, MessageAdditions, MessageEmbed, MessageOptions } from 'discord.js';
import { Color } from './color';
2021-05-13 03:20:36 +02:00
2021-05-13 16:30:28 +02:00
export class CommandError extends Error {
2021-05-13 03:20:36 +02:00
public constructor(public readonly content: APIMessageContentResolvable | (MessageOptions & { split?: false }) | MessageAdditions) {
super();
}
2021-05-13 16:18:31 +02:00
private static error(prefix: string, commandName: string, message: string): CommandError {
2021-05-13 16:30:28 +02:00
return new CommandError(new MessageEmbed()
2021-05-13 16:18:31 +02:00
.setColor(Color.red)
2021-05-13 16:30:28 +02:00
.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);
2021-05-13 16:18:31 +02:00
}
2021-05-13 16:45:08 +02:00
public static generic(commandName: string, message: string): CommandError {
return this.error('Error', commandName, message);
2021-05-13 16:45:08 +02:00
}
2021-05-13 03:20:36 +02:00
}