sixth chunk

This commit is contained in:
ITOH
2021-11-14 18:26:33 +01:00
parent a38beffdde
commit 9b6ba5ee90
15 changed files with 0 additions and 0 deletions
@@ -0,0 +1,30 @@
import type { ApplicationCommand } from "../../../types/interactions/commands/application_command.ts";
import type { EditGlobalApplicationCommand } from "../../../types/interactions/commands/edit_global_application_command.ts";
import type { Bot } from "../../../bot.ts";
import { makeOptionsForCommand } from "./create_slash_command.ts";
/**
* Edit an existing slash command. If this command did not exist, it will create it.
*/
export async function upsertSlashCommand(
bot: Bot,
commandId: bigint,
options: EditGlobalApplicationCommand,
guildId?: bigint
) {
[options] = bot.utils.validateSlashCommands(bot, [options]);
return await bot.rest.runMethod<ApplicationCommand>(
bot.rest,
"patch",
guildId
? bot.constants.endpoints.COMMANDS_GUILD_ID(bot.applicationId, guildId, commandId)
: bot.constants.endpoints.COMMANDS_ID(bot.applicationId, commandId),
{
name: options.name,
description: options.description,
type: options.type,
options: options.options ? makeOptionsForCommand(options.options) : undefined,
}
);
}