From d3163ca22e5b7d8292f9f6ccd444aa5c93771d92 Mon Sep 17 00:00:00 2001 From: Suneet Tipirneni <77477100+suneettipirneni@users.noreply.github.com> Date: Thu, 12 May 2022 19:38:59 -0400 Subject: [PATCH] feat: add support for application command permissions v2 (#415) --- deno/gateway/v10.ts | 1 + deno/gateway/v9.ts | 1 + .../_applicationCommands/permissions.ts | 13 +++++++++++-- .../v10/_interactions/applicationCommands.ts | 9 +++++++++ deno/payloads/v10/auditLog.ts | 15 +++++++++++++++ deno/payloads/v10/oauth2.ts | 6 ++++++ .../_applicationCommands/permissions.ts | 13 +++++++++++-- .../v9/_interactions/applicationCommands.ts | 9 +++++++++ deno/payloads/v9/auditLog.ts | 15 +++++++++++++++ deno/payloads/v9/oauth2.ts | 6 ++++++ deno/rest/v10/guild.ts | 1 + deno/rest/v10/interactions.ts | 17 +++++++++++------ deno/rest/v9/guild.ts | 1 + deno/rest/v9/interactions.ts | 12 +++++++----- gateway/v10.ts | 1 + gateway/v9.ts | 1 + .../_applicationCommands/permissions.ts | 13 +++++++++++-- .../v10/_interactions/applicationCommands.ts | 9 +++++++++ payloads/v10/auditLog.ts | 15 +++++++++++++++ payloads/v10/oauth2.ts | 6 ++++++ .../_applicationCommands/permissions.ts | 13 +++++++++++-- .../v9/_interactions/applicationCommands.ts | 9 +++++++++ payloads/v9/auditLog.ts | 15 +++++++++++++++ payloads/v9/oauth2.ts | 6 ++++++ rest/v10/guild.ts | 1 + rest/v10/interactions.ts | 17 +++++++++++------ rest/v9/guild.ts | 1 + rest/v9/interactions.ts | 12 +++++++----- 28 files changed, 208 insertions(+), 30 deletions(-) diff --git a/deno/gateway/v10.ts b/deno/gateway/v10.ts index a1628757..88d63fc3 100644 --- a/deno/gateway/v10.ts +++ b/deno/gateway/v10.ts @@ -195,6 +195,7 @@ export enum GatewayIntentBits { * https://discord.com/developers/docs/topics/gateway#commands-and-events-gateway-events */ export enum GatewayDispatchEvents { + ApplicationCommandPermissionsUpdate = 'APPLICATION_COMMAND_PERMISSIONS_UPDATE', ChannelCreate = 'CHANNEL_CREATE', ChannelDelete = 'CHANNEL_DELETE', ChannelPinsUpdate = 'CHANNEL_PINS_UPDATE', diff --git a/deno/gateway/v9.ts b/deno/gateway/v9.ts index 91d21910..95eb02dd 100644 --- a/deno/gateway/v9.ts +++ b/deno/gateway/v9.ts @@ -194,6 +194,7 @@ export enum GatewayIntentBits { * https://discord.com/developers/docs/topics/gateway#commands-and-events-gateway-events */ export enum GatewayDispatchEvents { + ApplicationCommandPermissionsUpdate = 'APPLICATION_COMMAND_PERMISSIONS_UPDATE', ChannelCreate = 'CHANNEL_CREATE', ChannelDelete = 'CHANNEL_DELETE', ChannelPinsUpdate = 'CHANNEL_PINS_UPDATE', diff --git a/deno/payloads/v10/_interactions/_applicationCommands/permissions.ts b/deno/payloads/v10/_interactions/_applicationCommands/permissions.ts index 38186f89..f325ac1f 100644 --- a/deno/payloads/v10/_interactions/_applicationCommands/permissions.ts +++ b/deno/payloads/v10/_interactions/_applicationCommands/permissions.ts @@ -27,11 +27,11 @@ export interface APIGuildApplicationCommandPermissions { */ export interface APIApplicationCommandPermission { /** - * The id of the role or user + * The id of the role, user or channel. Can also be a permission constant */ id: Snowflake; /** - * Role or user + * Role, user or channel */ type: ApplicationCommandPermissionType; /** @@ -46,4 +46,13 @@ export interface APIApplicationCommandPermission { export enum ApplicationCommandPermissionType { Role = 1, User, + Channel, } + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permissions-constants + */ +export const APIApplicationCommandPermissionsConstant = { + Everyone: (guildId: string | bigint): Snowflake => String(guildId), + AllChannels: (guildId: string | bigint): Snowflake => String(BigInt(guildId) - 1n), +}; diff --git a/deno/payloads/v10/_interactions/applicationCommands.ts b/deno/payloads/v10/_interactions/applicationCommands.ts index aa473780..f64ba416 100644 --- a/deno/payloads/v10/_interactions/applicationCommands.ts +++ b/deno/payloads/v10/_interactions/applicationCommands.ts @@ -70,10 +70,19 @@ export interface APIApplicationCommand { * The parameters for the `CHAT_INPUT` command, max 25 */ options?: APIApplicationCommandOption[]; + /** + * Set of permissions represented as a bitset + */ + default_member_permissions?: Permissions | null; + /** + * Indicates whether the command is available in DMs with the app, only for globally-scoped commands. By default, commands are visible + */ + dm_permission?: boolean | null; /** * Whether the command is enabled by default when the app is added to a guild * * If missing, this property should be assumed as `true` + * @deprecated Use `dm_permission` and/or `default_member_permissions` instead */ default_permission?: boolean; /** diff --git a/deno/payloads/v10/auditLog.ts b/deno/payloads/v10/auditLog.ts index 5928e9ee..6acca34e 100644 --- a/deno/payloads/v10/auditLog.ts +++ b/deno/payloads/v10/auditLog.ts @@ -16,6 +16,7 @@ import type { GuildScheduledEventEntityType, GuildScheduledEventStatus, } from './guildScheduledEvent.ts'; +import type { APIApplicationCommand } from './interactions.ts'; import type { APIRole } from './permissions.ts'; import type { StageInstancePrivacyLevel } from './stageInstance.ts'; import type { StickerFormatType } from './sticker.ts'; @@ -27,6 +28,12 @@ import type { Snowflake } from '../../globals.ts'; * https://discord.com/developers/docs/resources/audit-log#audit-log-object-audit-log-structure */ export interface APIAuditLog { + /** + * List of application commands found in the audit log + * + * See https://discord.com/developers/docs/interactions/application-commands#application-command-object + */ + application_commands: APIApplicationCommand[]; /** * Webhooks found in the audit log * @@ -171,6 +178,8 @@ export enum AuditLogEvent { ThreadCreate = 110, ThreadUpdate, ThreadDelete, + + ApplicationCommandPermissionUpdate = 121, } /** @@ -517,6 +526,12 @@ export type APIAuditLogChangeKeyPermissions = AuditLogChangeData<'permissions', */ export type APIAuditLogChangeKeyColor = AuditLogChangeData<'color', number>; +/** + * Represents a change where the key is a snowflake. + * Currently, the only known instance of this is returned when permissions for a command were updated () + */ +export type APIAuditLogChangeKeySnowflake = AuditLogChangeData; + /** * Returned when a role's hoist status is changed */ diff --git a/deno/payloads/v10/oauth2.ts b/deno/payloads/v10/oauth2.ts index 45e6244f..dc745bab 100644 --- a/deno/payloads/v10/oauth2.ts +++ b/deno/payloads/v10/oauth2.ts @@ -119,4 +119,10 @@ export enum OAuth2Scopes { * See https://discord.com/developers/docs/interactions/application-commands */ ApplicationsCommandsUpdate = 'applications.commands.update', + /** + * Allows your app to update permissions for its commands using a Bearer token - client credentials grant only + * + * See https://discord.com/developers/docs/interactions/application-commands + */ + ApplicationCommandsPermissionsUpdate = 'applications.commands.permissions.update', } diff --git a/deno/payloads/v9/_interactions/_applicationCommands/permissions.ts b/deno/payloads/v9/_interactions/_applicationCommands/permissions.ts index 38186f89..f325ac1f 100644 --- a/deno/payloads/v9/_interactions/_applicationCommands/permissions.ts +++ b/deno/payloads/v9/_interactions/_applicationCommands/permissions.ts @@ -27,11 +27,11 @@ export interface APIGuildApplicationCommandPermissions { */ export interface APIApplicationCommandPermission { /** - * The id of the role or user + * The id of the role, user or channel. Can also be a permission constant */ id: Snowflake; /** - * Role or user + * Role, user or channel */ type: ApplicationCommandPermissionType; /** @@ -46,4 +46,13 @@ export interface APIApplicationCommandPermission { export enum ApplicationCommandPermissionType { Role = 1, User, + Channel, } + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permissions-constants + */ +export const APIApplicationCommandPermissionsConstant = { + Everyone: (guildId: string | bigint): Snowflake => String(guildId), + AllChannels: (guildId: string | bigint): Snowflake => String(BigInt(guildId) - 1n), +}; diff --git a/deno/payloads/v9/_interactions/applicationCommands.ts b/deno/payloads/v9/_interactions/applicationCommands.ts index ad5a65ce..7e47657c 100644 --- a/deno/payloads/v9/_interactions/applicationCommands.ts +++ b/deno/payloads/v9/_interactions/applicationCommands.ts @@ -70,10 +70,19 @@ export interface APIApplicationCommand { * The parameters for the `CHAT_INPUT` command, max 25 */ options?: APIApplicationCommandOption[]; + /** + * Set of permissions represented as a bitset + */ + default_member_permissions?: Permissions | null; + /** + * Indicates whether the command is available in DMs with the app, only for globally-scoped commands. By default, commands are visible + */ + dm_permission?: boolean | null; /** * Whether the command is enabled by default when the app is added to a guild * * If missing, this property should be assumed as `true` + * @deprecated Use `dm_permission` and/or `default_member_permissions` instead */ default_permission?: boolean; /** diff --git a/deno/payloads/v9/auditLog.ts b/deno/payloads/v9/auditLog.ts index 5928e9ee..6acca34e 100644 --- a/deno/payloads/v9/auditLog.ts +++ b/deno/payloads/v9/auditLog.ts @@ -16,6 +16,7 @@ import type { GuildScheduledEventEntityType, GuildScheduledEventStatus, } from './guildScheduledEvent.ts'; +import type { APIApplicationCommand } from './interactions.ts'; import type { APIRole } from './permissions.ts'; import type { StageInstancePrivacyLevel } from './stageInstance.ts'; import type { StickerFormatType } from './sticker.ts'; @@ -27,6 +28,12 @@ import type { Snowflake } from '../../globals.ts'; * https://discord.com/developers/docs/resources/audit-log#audit-log-object-audit-log-structure */ export interface APIAuditLog { + /** + * List of application commands found in the audit log + * + * See https://discord.com/developers/docs/interactions/application-commands#application-command-object + */ + application_commands: APIApplicationCommand[]; /** * Webhooks found in the audit log * @@ -171,6 +178,8 @@ export enum AuditLogEvent { ThreadCreate = 110, ThreadUpdate, ThreadDelete, + + ApplicationCommandPermissionUpdate = 121, } /** @@ -517,6 +526,12 @@ export type APIAuditLogChangeKeyPermissions = AuditLogChangeData<'permissions', */ export type APIAuditLogChangeKeyColor = AuditLogChangeData<'color', number>; +/** + * Represents a change where the key is a snowflake. + * Currently, the only known instance of this is returned when permissions for a command were updated () + */ +export type APIAuditLogChangeKeySnowflake = AuditLogChangeData; + /** * Returned when a role's hoist status is changed */ diff --git a/deno/payloads/v9/oauth2.ts b/deno/payloads/v9/oauth2.ts index 45e6244f..dc745bab 100644 --- a/deno/payloads/v9/oauth2.ts +++ b/deno/payloads/v9/oauth2.ts @@ -119,4 +119,10 @@ export enum OAuth2Scopes { * See https://discord.com/developers/docs/interactions/application-commands */ ApplicationsCommandsUpdate = 'applications.commands.update', + /** + * Allows your app to update permissions for its commands using a Bearer token - client credentials grant only + * + * See https://discord.com/developers/docs/interactions/application-commands + */ + ApplicationCommandsPermissionsUpdate = 'applications.commands.permissions.update', } diff --git a/deno/rest/v10/guild.ts b/deno/rest/v10/guild.ts index e1453d2d..b9478b85 100644 --- a/deno/rest/v10/guild.ts +++ b/deno/rest/v10/guild.ts @@ -49,6 +49,7 @@ export type APIGuildCreatePartialChannel = StrictPartial< | 'rate_limit_per_user' | 'default_auto_archive_duration' | 'position' + | 'flags' > > & AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{ diff --git a/deno/rest/v10/interactions.ts b/deno/rest/v10/interactions.ts index 7b990194..a4567571 100644 --- a/deno/rest/v10/interactions.ts +++ b/deno/rest/v10/interactions.ts @@ -91,27 +91,29 @@ export type RESTPutAPIApplicationCommandsResult = APIApplicationCommand[]; /** * https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands */ -export type RESTGetAPIApplicationGuildCommandsResult = APIApplicationCommand[]; +export type RESTGetAPIApplicationGuildCommandsResult = Omit[]; /** * https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands */ -export type RESTGetAPIApplicationGuildCommandResult = APIApplicationCommand; +export type RESTGetAPIApplicationGuildCommandResult = Omit; /** * https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command */ -export type RESTPostAPIApplicationGuildCommandsJSONBody = RESTPostAPIApplicationCommandsJSONBody; +export type RESTPostAPIApplicationGuildCommandsJSONBody = Omit; /** * https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command */ -export type RESTPostAPIApplicationGuildCommandsResult = APIApplicationCommand; +export type RESTPostAPIApplicationGuildCommandsResult = Omit; /** * https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command */ -export type RESTPatchAPIApplicationGuildCommandJSONBody = StrictPartial; +export type RESTPatchAPIApplicationGuildCommandJSONBody = StrictPartial< + Omit +>; /** * https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command @@ -121,7 +123,10 @@ export type RESTPatchAPIApplicationGuildCommandResult = APIApplicationCommand; /** * https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands */ -export type RESTPutAPIApplicationGuildCommandsJSONBody = RESTPostAPIApplicationCommandsJSONBody[]; +export type RESTPutAPIApplicationGuildCommandsJSONBody = Omit< + RESTPostAPIApplicationCommandsJSONBody, + 'dm_permission' +>[]; /** * https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands diff --git a/deno/rest/v9/guild.ts b/deno/rest/v9/guild.ts index e087eeba..33c59deb 100644 --- a/deno/rest/v9/guild.ts +++ b/deno/rest/v9/guild.ts @@ -49,6 +49,7 @@ export type APIGuildCreatePartialChannel = StrictPartial< | 'rate_limit_per_user' | 'default_auto_archive_duration' | 'position' + | 'flags' > > & AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{ diff --git a/deno/rest/v9/interactions.ts b/deno/rest/v9/interactions.ts index 9a5bd6a8..f8916d4a 100644 --- a/deno/rest/v9/interactions.ts +++ b/deno/rest/v9/interactions.ts @@ -91,27 +91,29 @@ export type RESTPutAPIApplicationCommandsResult = APIApplicationCommand[]; /** * https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands */ -export type RESTGetAPIApplicationGuildCommandsResult = APIApplicationCommand[]; +export type RESTGetAPIApplicationGuildCommandsResult = Omit[]; /** * https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands */ -export type RESTGetAPIApplicationGuildCommandResult = APIApplicationCommand; +export type RESTGetAPIApplicationGuildCommandResult = Omit; /** * https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command */ -export type RESTPostAPIApplicationGuildCommandsJSONBody = RESTPostAPIApplicationCommandsJSONBody; +export type RESTPostAPIApplicationGuildCommandsJSONBody = Omit; /** * https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command */ -export type RESTPostAPIApplicationGuildCommandsResult = APIApplicationCommand; +export type RESTPostAPIApplicationGuildCommandsResult = Omit; /** * https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command */ -export type RESTPatchAPIApplicationGuildCommandJSONBody = StrictPartial; +export type RESTPatchAPIApplicationGuildCommandJSONBody = StrictPartial< + Omit +>; /** * https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command diff --git a/gateway/v10.ts b/gateway/v10.ts index 7c256035..1868f02b 100644 --- a/gateway/v10.ts +++ b/gateway/v10.ts @@ -195,6 +195,7 @@ export enum GatewayIntentBits { * https://discord.com/developers/docs/topics/gateway#commands-and-events-gateway-events */ export enum GatewayDispatchEvents { + ApplicationCommandPermissionsUpdate = 'APPLICATION_COMMAND_PERMISSIONS_UPDATE', ChannelCreate = 'CHANNEL_CREATE', ChannelDelete = 'CHANNEL_DELETE', ChannelPinsUpdate = 'CHANNEL_PINS_UPDATE', diff --git a/gateway/v9.ts b/gateway/v9.ts index c848d948..e72ec682 100644 --- a/gateway/v9.ts +++ b/gateway/v9.ts @@ -194,6 +194,7 @@ export enum GatewayIntentBits { * https://discord.com/developers/docs/topics/gateway#commands-and-events-gateway-events */ export enum GatewayDispatchEvents { + ApplicationCommandPermissionsUpdate = 'APPLICATION_COMMAND_PERMISSIONS_UPDATE', ChannelCreate = 'CHANNEL_CREATE', ChannelDelete = 'CHANNEL_DELETE', ChannelPinsUpdate = 'CHANNEL_PINS_UPDATE', diff --git a/payloads/v10/_interactions/_applicationCommands/permissions.ts b/payloads/v10/_interactions/_applicationCommands/permissions.ts index f8bdfe99..2b7e247e 100644 --- a/payloads/v10/_interactions/_applicationCommands/permissions.ts +++ b/payloads/v10/_interactions/_applicationCommands/permissions.ts @@ -27,11 +27,11 @@ export interface APIGuildApplicationCommandPermissions { */ export interface APIApplicationCommandPermission { /** - * The id of the role or user + * The id of the role, user or channel. Can also be a permission constant */ id: Snowflake; /** - * Role or user + * Role, user or channel */ type: ApplicationCommandPermissionType; /** @@ -46,4 +46,13 @@ export interface APIApplicationCommandPermission { export enum ApplicationCommandPermissionType { Role = 1, User, + Channel, } + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permissions-constants + */ +export const APIApplicationCommandPermissionsConstant = { + Everyone: (guildId: string | bigint): Snowflake => String(guildId), + AllChannels: (guildId: string | bigint): Snowflake => String(BigInt(guildId) - 1n), +}; diff --git a/payloads/v10/_interactions/applicationCommands.ts b/payloads/v10/_interactions/applicationCommands.ts index 5d3d1aa7..6fd938d9 100644 --- a/payloads/v10/_interactions/applicationCommands.ts +++ b/payloads/v10/_interactions/applicationCommands.ts @@ -70,10 +70,19 @@ export interface APIApplicationCommand { * The parameters for the `CHAT_INPUT` command, max 25 */ options?: APIApplicationCommandOption[]; + /** + * Set of permissions represented as a bitset + */ + default_member_permissions?: Permissions | null; + /** + * Indicates whether the command is available in DMs with the app, only for globally-scoped commands. By default, commands are visible + */ + dm_permission?: boolean | null; /** * Whether the command is enabled by default when the app is added to a guild * * If missing, this property should be assumed as `true` + * @deprecated Use `dm_permission` and/or `default_member_permissions` instead */ default_permission?: boolean; /** diff --git a/payloads/v10/auditLog.ts b/payloads/v10/auditLog.ts index 7d4e8193..d9194e28 100644 --- a/payloads/v10/auditLog.ts +++ b/payloads/v10/auditLog.ts @@ -16,6 +16,7 @@ import type { GuildScheduledEventEntityType, GuildScheduledEventStatus, } from './guildScheduledEvent'; +import type { APIApplicationCommand } from './interactions'; import type { APIRole } from './permissions'; import type { StageInstancePrivacyLevel } from './stageInstance'; import type { StickerFormatType } from './sticker'; @@ -27,6 +28,12 @@ import type { Snowflake } from '../../globals'; * https://discord.com/developers/docs/resources/audit-log#audit-log-object-audit-log-structure */ export interface APIAuditLog { + /** + * List of application commands found in the audit log + * + * See https://discord.com/developers/docs/interactions/application-commands#application-command-object + */ + application_commands: APIApplicationCommand[]; /** * Webhooks found in the audit log * @@ -171,6 +178,8 @@ export enum AuditLogEvent { ThreadCreate = 110, ThreadUpdate, ThreadDelete, + + ApplicationCommandPermissionUpdate = 121, } /** @@ -517,6 +526,12 @@ export type APIAuditLogChangeKeyPermissions = AuditLogChangeData<'permissions', */ export type APIAuditLogChangeKeyColor = AuditLogChangeData<'color', number>; +/** + * Represents a change where the key is a snowflake. + * Currently, the only known instance of this is returned when permissions for a command were updated () + */ +export type APIAuditLogChangeKeySnowflake = AuditLogChangeData; + /** * Returned when a role's hoist status is changed */ diff --git a/payloads/v10/oauth2.ts b/payloads/v10/oauth2.ts index 45e6244f..dc745bab 100644 --- a/payloads/v10/oauth2.ts +++ b/payloads/v10/oauth2.ts @@ -119,4 +119,10 @@ export enum OAuth2Scopes { * See https://discord.com/developers/docs/interactions/application-commands */ ApplicationsCommandsUpdate = 'applications.commands.update', + /** + * Allows your app to update permissions for its commands using a Bearer token - client credentials grant only + * + * See https://discord.com/developers/docs/interactions/application-commands + */ + ApplicationCommandsPermissionsUpdate = 'applications.commands.permissions.update', } diff --git a/payloads/v9/_interactions/_applicationCommands/permissions.ts b/payloads/v9/_interactions/_applicationCommands/permissions.ts index f8bdfe99..2b7e247e 100644 --- a/payloads/v9/_interactions/_applicationCommands/permissions.ts +++ b/payloads/v9/_interactions/_applicationCommands/permissions.ts @@ -27,11 +27,11 @@ export interface APIGuildApplicationCommandPermissions { */ export interface APIApplicationCommandPermission { /** - * The id of the role or user + * The id of the role, user or channel. Can also be a permission constant */ id: Snowflake; /** - * Role or user + * Role, user or channel */ type: ApplicationCommandPermissionType; /** @@ -46,4 +46,13 @@ export interface APIApplicationCommandPermission { export enum ApplicationCommandPermissionType { Role = 1, User, + Channel, } + +/** + * https://discord.com/developers/docs/interactions/application-commands#application-command-permissions-object-application-command-permissions-constants + */ +export const APIApplicationCommandPermissionsConstant = { + Everyone: (guildId: string | bigint): Snowflake => String(guildId), + AllChannels: (guildId: string | bigint): Snowflake => String(BigInt(guildId) - 1n), +}; diff --git a/payloads/v9/_interactions/applicationCommands.ts b/payloads/v9/_interactions/applicationCommands.ts index f44fea26..72dbebcb 100644 --- a/payloads/v9/_interactions/applicationCommands.ts +++ b/payloads/v9/_interactions/applicationCommands.ts @@ -70,10 +70,19 @@ export interface APIApplicationCommand { * The parameters for the `CHAT_INPUT` command, max 25 */ options?: APIApplicationCommandOption[]; + /** + * Set of permissions represented as a bitset + */ + default_member_permissions?: Permissions | null; + /** + * Indicates whether the command is available in DMs with the app, only for globally-scoped commands. By default, commands are visible + */ + dm_permission?: boolean | null; /** * Whether the command is enabled by default when the app is added to a guild * * If missing, this property should be assumed as `true` + * @deprecated Use `dm_permission` and/or `default_member_permissions` instead */ default_permission?: boolean; /** diff --git a/payloads/v9/auditLog.ts b/payloads/v9/auditLog.ts index 7d4e8193..d9194e28 100644 --- a/payloads/v9/auditLog.ts +++ b/payloads/v9/auditLog.ts @@ -16,6 +16,7 @@ import type { GuildScheduledEventEntityType, GuildScheduledEventStatus, } from './guildScheduledEvent'; +import type { APIApplicationCommand } from './interactions'; import type { APIRole } from './permissions'; import type { StageInstancePrivacyLevel } from './stageInstance'; import type { StickerFormatType } from './sticker'; @@ -27,6 +28,12 @@ import type { Snowflake } from '../../globals'; * https://discord.com/developers/docs/resources/audit-log#audit-log-object-audit-log-structure */ export interface APIAuditLog { + /** + * List of application commands found in the audit log + * + * See https://discord.com/developers/docs/interactions/application-commands#application-command-object + */ + application_commands: APIApplicationCommand[]; /** * Webhooks found in the audit log * @@ -171,6 +178,8 @@ export enum AuditLogEvent { ThreadCreate = 110, ThreadUpdate, ThreadDelete, + + ApplicationCommandPermissionUpdate = 121, } /** @@ -517,6 +526,12 @@ export type APIAuditLogChangeKeyPermissions = AuditLogChangeData<'permissions', */ export type APIAuditLogChangeKeyColor = AuditLogChangeData<'color', number>; +/** + * Represents a change where the key is a snowflake. + * Currently, the only known instance of this is returned when permissions for a command were updated () + */ +export type APIAuditLogChangeKeySnowflake = AuditLogChangeData; + /** * Returned when a role's hoist status is changed */ diff --git a/payloads/v9/oauth2.ts b/payloads/v9/oauth2.ts index 45e6244f..dc745bab 100644 --- a/payloads/v9/oauth2.ts +++ b/payloads/v9/oauth2.ts @@ -119,4 +119,10 @@ export enum OAuth2Scopes { * See https://discord.com/developers/docs/interactions/application-commands */ ApplicationsCommandsUpdate = 'applications.commands.update', + /** + * Allows your app to update permissions for its commands using a Bearer token - client credentials grant only + * + * See https://discord.com/developers/docs/interactions/application-commands + */ + ApplicationCommandsPermissionsUpdate = 'applications.commands.permissions.update', } diff --git a/rest/v10/guild.ts b/rest/v10/guild.ts index 83e3cd85..f01454de 100644 --- a/rest/v10/guild.ts +++ b/rest/v10/guild.ts @@ -49,6 +49,7 @@ export type APIGuildCreatePartialChannel = StrictPartial< | 'rate_limit_per_user' | 'default_auto_archive_duration' | 'position' + | 'flags' > > & AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{ diff --git a/rest/v10/interactions.ts b/rest/v10/interactions.ts index 4514d3a3..bf57f4cc 100644 --- a/rest/v10/interactions.ts +++ b/rest/v10/interactions.ts @@ -91,27 +91,29 @@ export type RESTPutAPIApplicationCommandsResult = APIApplicationCommand[]; /** * https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands */ -export type RESTGetAPIApplicationGuildCommandsResult = APIApplicationCommand[]; +export type RESTGetAPIApplicationGuildCommandsResult = Omit[]; /** * https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands */ -export type RESTGetAPIApplicationGuildCommandResult = APIApplicationCommand; +export type RESTGetAPIApplicationGuildCommandResult = Omit; /** * https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command */ -export type RESTPostAPIApplicationGuildCommandsJSONBody = RESTPostAPIApplicationCommandsJSONBody; +export type RESTPostAPIApplicationGuildCommandsJSONBody = Omit; /** * https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command */ -export type RESTPostAPIApplicationGuildCommandsResult = APIApplicationCommand; +export type RESTPostAPIApplicationGuildCommandsResult = Omit; /** * https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command */ -export type RESTPatchAPIApplicationGuildCommandJSONBody = StrictPartial; +export type RESTPatchAPIApplicationGuildCommandJSONBody = StrictPartial< + Omit +>; /** * https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command @@ -121,7 +123,10 @@ export type RESTPatchAPIApplicationGuildCommandResult = APIApplicationCommand; /** * https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands */ -export type RESTPutAPIApplicationGuildCommandsJSONBody = RESTPostAPIApplicationCommandsJSONBody[]; +export type RESTPutAPIApplicationGuildCommandsJSONBody = Omit< + RESTPostAPIApplicationCommandsJSONBody, + 'dm_permission' +>[]; /** * https://discord.com/developers/docs/interactions/application-commands#bulk-overwrite-guild-application-commands diff --git a/rest/v9/guild.ts b/rest/v9/guild.ts index 7eb18a24..3117b13b 100644 --- a/rest/v9/guild.ts +++ b/rest/v9/guild.ts @@ -49,6 +49,7 @@ export type APIGuildCreatePartialChannel = StrictPartial< | 'rate_limit_per_user' | 'default_auto_archive_duration' | 'position' + | 'flags' > > & AddUndefinedToPossiblyUndefinedPropertiesOfInterface<{ diff --git a/rest/v9/interactions.ts b/rest/v9/interactions.ts index da768b36..124a4fe3 100644 --- a/rest/v9/interactions.ts +++ b/rest/v9/interactions.ts @@ -91,27 +91,29 @@ export type RESTPutAPIApplicationCommandsResult = APIApplicationCommand[]; /** * https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands */ -export type RESTGetAPIApplicationGuildCommandsResult = APIApplicationCommand[]; +export type RESTGetAPIApplicationGuildCommandsResult = Omit[]; /** * https://discord.com/developers/docs/interactions/application-commands#get-guild-application-commands */ -export type RESTGetAPIApplicationGuildCommandResult = APIApplicationCommand; +export type RESTGetAPIApplicationGuildCommandResult = Omit; /** * https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command */ -export type RESTPostAPIApplicationGuildCommandsJSONBody = RESTPostAPIApplicationCommandsJSONBody; +export type RESTPostAPIApplicationGuildCommandsJSONBody = Omit; /** * https://discord.com/developers/docs/interactions/application-commands#create-guild-application-command */ -export type RESTPostAPIApplicationGuildCommandsResult = APIApplicationCommand; +export type RESTPostAPIApplicationGuildCommandsResult = Omit; /** * https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command */ -export type RESTPatchAPIApplicationGuildCommandJSONBody = StrictPartial; +export type RESTPatchAPIApplicationGuildCommandJSONBody = StrictPartial< + Omit +>; /** * https://discord.com/developers/docs/interactions/application-commands#edit-guild-application-command