From ae1361c31ed0cd97be1eacc18650d871d2e27a65 Mon Sep 17 00:00:00 2001 From: ITOH <72305210+itohatweb@users.noreply.github.com> Date: Mon, 26 Apr 2021 20:23:56 +0100 Subject: [PATCH] Create batch_edit_slash_command_permissions.ts --- .../batch_edit_slash_command_permissions.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/helpers/commands/batch_edit_slash_command_permissions.ts diff --git a/src/helpers/commands/batch_edit_slash_command_permissions.ts b/src/helpers/commands/batch_edit_slash_command_permissions.ts new file mode 100644 index 000000000..cf1adfa46 --- /dev/null +++ b/src/helpers/commands/batch_edit_slash_command_permissions.ts @@ -0,0 +1,17 @@ +import { applicationId } from "../../bot.ts"; +import { rest } from "../../rest/rest.ts"; +import { ApplicationCommandPermissions } from "../../types/interactions/application_command_permissions.ts"; +import { endpoints } from "../../util/constants.ts"; +import { snakeKeysToCamelCase } from "../../util/utils.ts"; + +/** Batch edits permissions for all commands in a guild. Takes an array of partial GuildApplicationCommandPermissions objects including `id` and `permissions`. */ +export async function batchEditSlashCommandPermissions( + guildId: string, + options: { id: string; permissions: ApplicationCommandPermissions[] }[], +) { + return await rest.runMethod( + "put", + endpoints.COMMANDS_PERMISSIONS(applicationId, guildId), + snakeKeysToCamelCase(options), + ); +}