UNPKG

@shadow-dev/core

Version:

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

32 lines (31 loc) 991 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ButtonManager = void 0; const util_1 = require("../util"); class ButtonManager { constructor(client) { this.client = client; } registerButton(button) { ButtonManager.buttons.set(button.customId, button); } async handleInteraction(interaction) { let button; if (interaction.customId.includes(":")) { const parsedId = (0, util_1.splitSpecialId)(interaction.customId); const newId = `${parsedId.feature}:${parsedId.action}:{id}`; button = ButtonManager.buttons.get(newId); } else { button = ButtonManager.buttons.get(interaction.customId); } if (button) { await button.run(interaction, this.client); } } static getAllButtons() { return ButtonManager.buttons; } } exports.ButtonManager = ButtonManager; ButtonManager.buttons = new Map();