UNPKG

@ayanaware/bentocord

Version:

Bentocord is a Bento plugin designed to rapidly build fully functional Discord Bots.

68 lines 3.57 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.SlashCommand = void 0; const bento_1 = require("@ayanaware/bento"); const CommandManager_1 = require("../CommandManager"); const SlashManager_1 = require("../SlashManager"); const OptionType_1 = require("../constants/OptionType"); const SuppressorType_1 = require("../constants/SuppressorType"); class SlashCommand { constructor() { this.name = '@ayanaware/bentocord:Slash'; this.parent = CommandManager_1.CommandManager; this.replaceable = true; this.definition = { name: ['slash', 'manageslash'], description: 'manage slash commands', options: [ { type: OptionType_1.OptionType.SUB_COMMAND, name: 'resync', description: 'resync slash commands', options: [ { type: OptionType_1.OptionType.STRING, name: 'guild', description: 'optional guild', required: false }, { type: OptionType_1.OptionType.STRING, name: 'prefix', description: 'optional prefix', required: false }, ] }, { type: OptionType_1.OptionType.SUB_COMMAND, name: 'purge', description: 'purge slash commands from api', options: [ { type: OptionType_1.OptionType.STRING, name: 'guild', description: 'optional guild', required: false }, { type: OptionType_1.OptionType.STRING, name: 'prefix', description: 'optional prefix', required: false }, ] }, ], suppressors: [SuppressorType_1.SuppressorType.BOT_OWNER], registerSlash: false, hidden: true, }; } async execute(ctx, options) { if (options.resync) { const resync = options.resync; let commands = await this.sm.convertCommands(); if (resync.prefix) commands = commands.map(c => ({ ...c, name: `${resync.prefix}${c.name}` })); const opts = { delete: resync.prefix ? resync.prefix : true }; if (resync.guild) opts.guildId = resync.guild; await this.sm.syncCommands(commands, opts); return ctx.createResponse('Sync successful'); } else if (options.purge) { const purge = options.purge; const opts = { delete: purge.prefix ? purge.prefix : true }; if (purge.guild) opts.guildId = purge.guild; await this.sm.syncCommands([], opts); return ctx.createResponse('Purge successful'); } } } __decorate([ (0, bento_1.Inject)(), __metadata("design:type", SlashManager_1.SlashManager) ], SlashCommand.prototype, "sm", void 0); exports.SlashCommand = SlashCommand; //# sourceMappingURL=Slash.js.map