feat(permissions): Adds server permissions

This commit is contained in:
Michel Fedde 2025-06-24 20:58:46 +02:00
parent d46bbd84c5
commit cf9c88a2d6
24 changed files with 415 additions and 69 deletions

View file

@ -17,6 +17,7 @@ import {MessageActionRowComponentBuilder} from "@discordjs/builders";
import {ComponentInteractionEvent} from "../Events/EventClasses/ComponentInteractionEvent";
import {MenuTraversal} from "./MenuTraversal";
import {Prompt} from "./Modals/Prompt";
import _ from "lodash";
export class MenuRenderer {
private readonly menuId: string;
@ -86,20 +87,14 @@ export class MenuRenderer {
private getComponentForMenuItem(menuItem: AnyMenuItem): ActionRowBuilder<MessageActionRowComponentBuilder>[] {
if (menuItem.type === MenuItemType.Collection) {
const rowCount = Math.ceil(menuItem.children.length / MenuRenderer.MAX_BUTTON_PER_ROW);
if (rowCount > MenuRenderer.MAX_USER_ROW_COUNT) {
const rows = _.chunk<AnyMenuItem>(menuItem.children, MenuRenderer.MAX_BUTTON_PER_ROW);
if (rows.length > MenuRenderer.MAX_USER_ROW_COUNT) {
throw new TypeError(
`A collection can only have a max of ${MenuRenderer.MAX_USER_ROW_COUNT * MenuRenderer.MAX_BUTTON_PER_ROW} entries!`
);
}
const rows = Array.from(Array(rowCount).keys())
.map((index) => {
const childStart = index * MenuRenderer.MAX_BUTTON_PER_ROW;
return menuItem.children.slice(childStart, MenuRenderer.MAX_BUTTON_PER_ROW);
})
return rows.reverse()
return rows
.map((items) => new ActionRowBuilder<ButtonBuilder>()
.setComponents(
...items.map(item => new ButtonBuilder()