UNPKG

discord-bot-cli

Version:

An easy way to build a command-based discord bot with discord.js.

33 lines (32 loc) 1.45 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const discord_js_1 = require("discord.js"); const makeCommand_1 = require("../other/makeCommand"); const ListUtils_1 = require("../other/ListUtils"); const reply_1 = require("../utils/reply"); const cmd = makeCommand_1.makeCommand("list", { description: "Display a list of all avaible commands.", flags: { detail: { type: "boolean", shortcut: "d", description: "Provide commands description.", }, }, examples: ["list", "list -d"], }); cmd.executor = async (_a, { detail }, { commandSet, options, message }) => { const raw = ListUtils_1.getListRawData(commandSet, options.localization); let commands = options.devIDs.includes(message.author.id) ? raw.commands : raw.commands.filter(c => !c.command.devOnly); if (!options.devIDs.includes(message.author.id) || !options.skipDevsPermissionsChecking) commands = commands.filter(c => c.command.checkPermissions(message)); const embed = new discord_js_1.MessageEmbed().setColor("#0099ff").setTitle(options.localization.list.title); const descriptions = detail ? commands.map(c => `\`${c.command.name}\` ${c.description}`).join("\n") : commands.map(c => `\`${c.command.name}\``).join(" "); embed.setDescription(descriptions); await reply_1.reply(message, { embed }); }; exports.default = cmd;