UNPKG

artibot

Version:

Modern, fast and modular open-source Discord bot

36 lines 1.27 kB
import selectMenuError from "../messages/selectMenuError.js"; import log from "../logger.js"; import { SelectMenuOption } from "../modules.js"; export const name = "interactionCreate"; export async function execute(interaction, artibot) { // Checks if the interaction is a select menu interaction if (!interaction.isStringSelectMenu()) return; const { localizer, modules } = artibot; let command; for (const [, module] of modules) { if (command) break; for (const part of module.parts) { if (command) break; if ((part instanceof SelectMenuOption) && part.id == interaction.customId) command = part; } } // If the interaction is not a registered dropdown, return error message. if (!command) return selectMenuError(interaction, artibot); // A try to execute the interaction. try { await command.execute(interaction, artibot); } catch (err) { log("SelectMenuHandler", err.message, "warn", true); interaction.reply({ content: localizer._("An error occured while executing this menu option."), ephemeral: true }); } } //# sourceMappingURL=selectMenuHandler.js.map