Files
discordeno/helpers/interactions/commands/editApplicationCommandPermissions.ts
ITOH b00504ce07 perf(plugins/helpers,rest,site,template)!: uppercase rest methods (#2252)
* perf(plugins/helpers,rest,site,template)!: uppercase rest methods
There is no need for us to pass the methods in lower case and then use the `toUpperCase()` method everywhere. Therefore this PR changes every lowercase method to be uppercase (eg. `"get"` => `"GET"`).

* template is old version
2022-05-25 20:45:51 +02:00

38 lines
1.3 KiB
TypeScript

import type { Bot } from "../../../bot.ts";
import { DiscordGuildApplicationCommandPermissions } from "../../../types/discord.ts";
import { ApplicationCommandPermissionTypes } from "../../../types/shared.ts";
/** Edits command permissions for a specific command for your application in a guild. */
export async function editApplicationCommandPermissions(
bot: Bot,
guildId: bigint,
commandId: bigint,
/** Bearer token which has the `applications.commands.permissions.update` scope and also access to this guild. */
bearerToken: string,
options: ApplicationCommandPermissions[],
) {
const result = await bot.rest.runMethod<DiscordGuildApplicationCommandPermissions>(
bot.rest,
"PUT",
bot.constants.routes.COMMANDS_PERMISSION(bot.applicationId, guildId, commandId),
{
permissions: options,
},
{
headers: { authorization: `Bearer ${bearerToken}` },
},
);
return bot.transformers.applicationCommandPermission(bot, result);
}
/** https://discord.com/developers/docs/interactions/application-commands#edit-application-command-permissions */
export interface ApplicationCommandPermissions {
/** The id of the role or user */
id: string;
/** Role or User */
type: ApplicationCommandPermissionTypes;
/** `true` to allow, `false`, to disallow */
permission: boolean;
}