feat(polish): Adds EmbedLibrary

This commit is contained in:
Michel Fedde 2025-06-24 21:59:55 +02:00
parent cf9c88a2d6
commit b3d0b3a90c
12 changed files with 240 additions and 136 deletions

View file

@ -1,4 +1,5 @@
import {inlineCode} from "discord.js";
import {EmbedBuilder, inlineCode} from "discord.js";
import {EmbedLibrary, EmbedType} from "./EmbedLibrary";
export class PermissionError extends Error {
shouldLog: boolean = false;
@ -10,15 +11,22 @@ export class PermissionError extends Error {
super(message);
}
public getDiscordMessage(e: PermissionError): string {
let userMessage = `:x: You can not perform this action! ${inlineCode(e.message)}`
if (e.tryInstead) {
userMessage += `
public getEmbed(e: PermissionError): EmbedBuilder {
const embed = EmbedLibrary.base(
"You can not perform this action!",
inlineCode(e.message),
EmbedType.Error
).setFooter({
text: "Type: Permission"
});
You can try the following:
${inlineCode(e.tryInstead)}`
if (e.tryInstead) {
embed.addFields({
name: "You can try the following:",
value: e.tryInstead
})
}
return userMessage;
return embed;
}
}