UNPKG

@grammyjs/commands

Version:
19 lines (18 loc) 915 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.setBotCommands = setBotCommands; const errors_js_1 = require("./errors.js"); /** * Performs validation and sets the provided commands for the bot. * @param api Instance of the Api class for the bot the commands are being set for. * @param commandParams List of commands to set. * @param uncompliantCommands List of commands that do not comply with the Bot API rules. * @param options Options object` */ async function setBotCommands(api, commandParams, uncompliantCommands, options) { const { ignoreUncompliantCommands = false } = options !== null && options !== void 0 ? options : {}; if (uncompliantCommands.length && !ignoreUncompliantCommands) { throw new errors_js_1.UncompliantCommandsError(uncompliantCommands); } await Promise.all(commandParams.map((args) => api.raw.setMyCommands(args))); }