pnp-scheduler/source/Discord/UserError.ts

33 lines
No EOL
694 B
TypeScript

import {EmbedBuilder, inlineCode} from "discord.js";
import {EmbedLibrary, EmbedType} from "./EmbedLibrary";
export class UserError extends Error {
shouldLog: boolean = false;
constructor(
message: string,
public readonly tryInstead: string | null = null
) {
super(message);
}
public getEmbed(e: UserError): EmbedBuilder {
const embed = EmbedLibrary.base(
"Please validate your request!",
inlineCode(e.message),
EmbedType.Error
).setFooter({
text: "Type: Request"
});
if (e.tryInstead) {
embed.addFields({
name: "You can try the following:",
value: e.tryInstead
})
}
return embed;
}
}