24 lines
No EOL
525 B
TypeScript
24 lines
No EOL
525 B
TypeScript
import {inlineCode} from "discord.js";
|
|
|
|
export class PermissionError extends Error {
|
|
shouldLog: boolean = false;
|
|
|
|
constructor(
|
|
message: string,
|
|
public readonly tryInstead: string | null = null
|
|
) {
|
|
super(message);
|
|
}
|
|
|
|
public getDiscordMessage(e: PermissionError): string {
|
|
let userMessage = `:x: You can not perform this action! ${inlineCode(e.message)}`
|
|
if (e.tryInstead) {
|
|
userMessage += `
|
|
|
|
You can try the following:
|
|
${inlineCode(e.tryInstead)}`
|
|
}
|
|
|
|
return userMessage;
|
|
}
|
|
} |