UNPKG

@shadow-dev/core

Version:

A modular core framework for Discord bot development, providing commands, buttons, menus, middleware, and more.

33 lines (32 loc) 1.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MenuManager = void 0; const util_1 = require("../util"); class MenuManager { constructor(client) { this.client = client; } registerMenu(menu) { MenuManager.menus.set(menu.customId, menu); } async handleInteraction(interaction) { // const menu = MenuManager.menus.get(interaction.customId); let menu; if (interaction.customId.includes(":")) { const parsedId = (0, util_1.splitSpecialId)(interaction.customId); const newId = `${parsedId.feature}:${parsedId.action}:{id}`; menu = MenuManager.menus.get(newId); } else { menu = MenuManager.menus.get(interaction.customId); } if (menu) { await menu.run(interaction, this.client); } } static getAllMenus() { return MenuManager.menus; // Provide a method to access all commands if needed } } exports.MenuManager = MenuManager; MenuManager.menus = new Map();