UNPKG

myteams-api

Version:

An MyTeams Module to use discord.js and Twitch API easily

40 lines 1.89 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.InteractionEvent = void 0; const Error_1 = require("../Utils/Error"); const chalk_1 = __importDefault(require("chalk")); async function InteractionEvent(client, Collection) { console.log(chalk_1.default.yellow("[MyTeams] (Warning) >> This interaction event its for our slash command handler, if you don't use our slash handler, please don't use this function or you will get many errors")); if (!client) throw new Error_1.MyTeamsError('Please provide a Discord client.'); if (!Collection) throw new Error_1.MyTeamsError('Please provide a slash command collection.'); client.on('interactionCreate', async (interaction) => { if (interaction.isCommand()) { await interaction.deferReply({ ephemeral: false }).catch(() => { }); const cmd = Collection.get(interaction.commandName); if (!cmd) { interaction.editReply({ content: "That command doesn't exists!" }); } const args = []; for (let option of interaction.options.data) { if (option.type === 'SUB_COMMAND') { if (option.name) args.push(option.name); option.options?.forEach((x) => { if (x.value) args.push(x.value); }); } else if (option.value) args.push(option.value); } cmd.run(client, interaction, args); } }); } exports.InteractionEvent = InteractionEvent; //# sourceMappingURL=interactionCreate.js.map