mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-02 00:40:07 +00:00
38 lines
1.3 KiB
TypeScript
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;
|
|
}
|