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

@ -18,12 +18,12 @@ import {ComponentInteractionEvent} from "../Events/EventClasses/ComponentInterac
import {MenuTraversal} from "./MenuTraversal";
import {Prompt} from "./Modals/Prompt";
import _ from "lodash";
import {EmbedLibrary} from "../Discord/EmbedLibrary";
export class MenuRenderer {
private readonly menuId: string;
private eventId: Nullable<string>;
private exitButton: ButtonBuilder;
private backButton: ButtonBuilder;
private static MAX_BUTTON_PER_ROW = 5;
private static MAX_ROWS = 5;
@ -33,18 +33,13 @@ export class MenuRenderer {
constructor(
private readonly traversal: MenuTraversal,
private readonly eventHandler: EventHandler|null = null,
private readonly iconCache: Nullable<IconCache> = null
private readonly iconCache: Nullable<IconCache> = null,
private readonly rootName: string = '',
) {
this.eventHandler ??= Container.get<EventHandler>(EventHandler.name);
this.iconCache ??= Container.get<IconCache>(IconCache.name);
this.menuId = randomUUID();
this.exitButton = new ButtonBuilder()
.setLabel("Exit")
.setStyle(ButtonStyle.Danger)
.setCustomId(this.getInteractionId("EXIT"))
.setEmoji(this.iconCache?.get("door_open_solid_white") ?? '');
this.backButton = new ButtonBuilder()
.setLabel("Back")
.setStyle(ButtonStyle.Secondary)
@ -119,11 +114,11 @@ export class MenuRenderer {
}
private getEmbed(): EmbedBuilder {
const embed = new EmbedBuilder()
.setTitle(this.traversal.currentMenuItem.label)
.setDescription(this.traversal.currentMenuItem.description ?? '')
.setAuthor({
name: "/ " + this.traversal.path.join(' / ')
const embed = EmbedLibrary.base(
this.traversal.currentMenuItem.label,
this.traversal.currentMenuItem.description ?? '',
).setFooter({
text: this.rootName + " / " + this.traversal.getTraversedLabels().join(' / ')
});
if (this.traversal.currentMenuItem.type === MenuItemType.Field) {