diff --git a/.github/workflows/publish-next.yml b/.github/workflows/publish-next.yml index 25d3546c..108cc8f8 100644 --- a/.github/workflows/publish-next.yml +++ b/.github/workflows/publish-next.yml @@ -28,12 +28,12 @@ jobs: run: npx standard-version env: NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} - + - name: Deprecate old versions run: npm deprecate discord-api-types@"~$(jq --raw-output '.version' package.json)-next" "No longer supported. Install the latest @next release" || true env: NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} - + - name: Publish new version run: | npm version --git-tag-version=false $(jq --raw-output '.version' package.json)-next.$(git rev-parse --short HEAD).$(date +%s) diff --git a/deno/gateway/v8.ts b/deno/gateway/v8.ts index 3050e7c5..276afad1 100644 --- a/deno/gateway/v8.ts +++ b/deno/gateway/v8.ts @@ -16,6 +16,7 @@ import type { APIMessageComponentInteraction, APIRole, APIStageInstance, + APISticker, APIUnavailableGuild, APIUser, GatewayActivity, @@ -170,7 +171,7 @@ export enum GatewayIntentBits { Guilds = 1 << 0, GuildMembers = 1 << 1, GuildBans = 1 << 2, - GuildEmojis = 1 << 3, + GuildEmojisAndStickers = 1 << 3, GuildIntegrations = 1 << 4, GuildWebhooks = 1 << 5, GuildInvites = 1 << 6, @@ -208,6 +209,7 @@ export enum GatewayDispatchEvents { GuildRoleCreate = 'GUILD_ROLE_CREATE', GuildRoleDelete = 'GUILD_ROLE_DELETE', GuildRoleUpdate = 'GUILD_ROLE_UPDATE', + GuildStickersUpdate = 'GUILD_STICKERS_UPDATE', GuildUpdate = 'GUILD_UPDATE', IntegrationCreate = 'INTEGRATION_CREATE', IntegrationDelete = 'INTEGRATION_DELETE', @@ -266,6 +268,7 @@ export type GatewayDispatchPayload = | GatewayGuildModifyDispatch | GatewayGuildRoleDeleteDispatch | GatewayGuildRoleModifyDispatch + | GatewayGuildStickersUpdateDispatch | GatewayIntegrationCreateDispatch | GatewayIntegrationDeleteDispatch | GatewayIntegrationUpdateDispatch @@ -638,6 +641,30 @@ export interface GatewayGuildEmojisUpdateDispatchData { emojis: APIEmoji[]; } +/** + * https://discord.com/developers/docs/topics/gateway#guild-stickers-update + */ +export type GatewayGuildStickersUpdateDispatch = DataPayload< + GatewayDispatchEvents.GuildStickersUpdate, + GatewayGuildStickersUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-stickers-update + */ +export interface GatewayGuildStickersUpdateDispatchData { + /** + * ID of the guild + */ + guild_id: Snowflake; + /** + * Array of stickers + * + * See https://discord.com/developers/docs/resources/sticker#sticker-object + */ + stickers: APISticker[]; +} + /** * https://discord.com/developers/docs/topics/gateway#guild-integrations-update */ diff --git a/deno/gateway/v9.ts b/deno/gateway/v9.ts index 2cdcfc7a..36488df3 100644 --- a/deno/gateway/v9.ts +++ b/deno/gateway/v9.ts @@ -16,6 +16,7 @@ import type { APIMessageComponentInteraction, APIRole, APIStageInstance, + APISticker, APIThreadMember, APIUnavailableGuild, APIUser, @@ -173,7 +174,7 @@ export enum GatewayIntentBits { Guilds = 1 << 0, GuildMembers = 1 << 1, GuildBans = 1 << 2, - GuildEmojis = 1 << 3, + GuildEmojisAndStickers = 1 << 3, GuildIntegrations = 1 << 4, GuildWebhooks = 1 << 5, GuildInvites = 1 << 6, @@ -211,6 +212,7 @@ export enum GatewayDispatchEvents { GuildRoleCreate = 'GUILD_ROLE_CREATE', GuildRoleDelete = 'GUILD_ROLE_DELETE', GuildRoleUpdate = 'GUILD_ROLE_UPDATE', + GuildStickersUpdate = 'GUILD_STICKERS_UPDATE', GuildUpdate = 'GUILD_UPDATE', IntegrationCreate = 'INTEGRATION_CREATE', IntegrationDelete = 'INTEGRATION_DELETE', @@ -275,6 +277,7 @@ export type GatewayDispatchPayload = | GatewayGuildModifyDispatch | GatewayGuildRoleDeleteDispatch | GatewayGuildRoleModifyDispatch + | GatewayGuildStickersUpdateDispatch | GatewayIntegrationCreateDispatch | GatewayIntegrationDeleteDispatch | GatewayIntegrationUpdateDispatch @@ -648,6 +651,30 @@ export interface GatewayGuildEmojisUpdateDispatchData { emojis: APIEmoji[]; } +/** + * https://discord.com/developers/docs/topics/gateway#guild-stickers-update + */ +export type GatewayGuildStickersUpdateDispatch = DataPayload< + GatewayDispatchEvents.GuildStickersUpdate, + GatewayGuildStickersUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-stickers-update + */ +export interface GatewayGuildStickersUpdateDispatchData { + /** + * ID of the guild + */ + guild_id: Snowflake; + /** + * Array of stickers + * + * See https://discord.com/developers/docs/resources/sticker#sticker-object + */ + stickers: APISticker[]; +} + /** * https://discord.com/developers/docs/topics/gateway#guild-integrations-update */ diff --git a/deno/payloads/v8/auditLog.ts b/deno/payloads/v8/auditLog.ts index b43955f5..546d6cd7 100644 --- a/deno/payloads/v8/auditLog.ts +++ b/deno/payloads/v8/auditLog.ts @@ -3,7 +3,7 @@ */ import type { Snowflake } from '../../globals.ts'; -import type { APIOverwrite, ChannelType } from './channel.ts'; +import type { APIOverwrite } from './channel.ts'; import type { APIGuildIntegration, GuildDefaultMessageNotifications, @@ -13,6 +13,7 @@ import type { IntegrationExpireBehavior, } from './guild.ts'; import type { APIRole } from './permissions.ts'; +import type { StickerFormatType } from './sticker.ts'; import type { APIUser } from './user.ts'; import type { APIWebhook } from './webhook.ts'; import type { StageInstancePrivacyLevel } from './stageInstance.ts'; @@ -136,10 +137,13 @@ export enum AuditLogEvent { IntegrationCreate = 80, IntegrationUpdate, IntegrationDelete, - - StageInstanceCreate = 83, + StageInstanceCreate, StageInstanceUpdate, StageInstanceDelete, + + StickerCreate = 90, + StickerUpdate, + StickerDelete, } /** @@ -293,15 +297,20 @@ export type APIAuditLogChange = | APIAuditLogChangeKeyExpireBehavior | APIAuditLogChangeKeyExpireGracePeriod | APIAuditLogChangeKeyUserLimit - | APIAuditLogChangeKeyPrivacyLevel; + | APIAuditLogChangeKeyPrivacyLevel + | APIAuditLogChangeKeyTags + | APIAuditLogChangeKeyFormatType + | APIAuditLogChangeKeyAsset + | APIAuditLogChangeKeyAvailable + | APIAuditLogChangeKeyGuildID; /** - * Returned when a guild's name is changed + * Returned when an entity's name is changed */ export type APIAuditLogChangeKeyName = AuditLogChangeData<'name', string>; /** - * Returned when a guild's description is changed + * Returned when a guild's or sticker's description is changed */ export type APIAuditLogChangeKeyDescription = AuditLogChangeData<'description', string>; @@ -550,7 +559,7 @@ export type APIAuditLogChangeKeyID = AuditLogChangeData<'id', Snowflake>; /** * The type of entity created */ -export type APIAuditLogChangeKeyType = AuditLogChangeData<'type', ChannelType | string>; +export type APIAuditLogChangeKeyType = AuditLogChangeData<'type', number | string>; /** * Returned when an integration's enable_emoticons is changed @@ -577,6 +586,31 @@ export type APIAuditLogChangeKeyUserLimit = AuditLogChangeData<'user_limit', num */ export type APIAuditLogChangeKeyPrivacyLevel = AuditLogChangeData<'privacy_level', StageInstancePrivacyLevel>; +/** + * Returned when a sticker's related emoji is changed + */ +export type APIAuditLogChangeKeyTags = AuditLogChangeData<'tags', string>; + +/** + * Returned when a sticker's format_type is changed + */ +export type APIAuditLogChangeKeyFormatType = AuditLogChangeData<'format_type', StickerFormatType>; + +/** + * Empty string + */ +export type APIAuditLogChangeKeyAsset = AuditLogChangeData<'asset', ''>; + +/** + * Returned when a sticker's availability is changed + */ +export type APIAuditLogChangeKeyAvailable = AuditLogChangeData<'available', boolean>; + +/** + * Returned when a sticker's guild_id is changed + */ +export type APIAuditLogChangeKeyGuildID = AuditLogChangeData<'guild_id', Snowflake>; + interface AuditLogChangeData { key: K; /** diff --git a/deno/payloads/v8/channel.ts b/deno/payloads/v8/channel.ts index 95864e47..4cb60c80 100644 --- a/deno/payloads/v8/channel.ts +++ b/deno/payloads/v8/channel.ts @@ -6,8 +6,9 @@ import type { Permissions, Snowflake } from '../../globals.ts'; import type { APIPartialEmoji } from './emoji.ts'; import type { APIGuildMember } from './guild.ts'; import type { APIMessageInteraction } from './interactions.ts'; -import { APIApplication } from './oauth2.ts'; +import type { APIApplication } from './oauth2.ts'; import type { APIRole } from './permissions.ts'; +import type { APISticker, APIStickerItem } from './sticker.ts'; import type { APIUser } from './user.ts'; /** @@ -318,12 +319,6 @@ export interface APIMessage { * See https://en.wikipedia.org/wiki/Bit_field */ flags?: MessageFlags; - /** - * The stickers sent with the message (bots currently can only receive messages with stickers, not send) - * - * See https://discord.com/developers/docs/resources/channel#message-object-message-sticker-structure - */ - stickers?: APISticker[]; /** * The message associated with the `message_reference` * @@ -346,6 +341,19 @@ export interface APIMessage { * Sent if the message contains components like buttons, action rows, or other interactive components */ components?: APIActionRowComponent[]; + /** + * Sent if the message contains stickers + * + * See https://discord.com/developers/docs/resources/sticker#sticker-item-object + */ + sticker_items?: APIStickerItem[]; + /** + * The stickers sent with the message + * + * See https://discord.com/developers/docs/resources/sticker#sticker-object + * @deprecated Use `sticker_items` instead + */ + stickers?: APISticker[]; } /** @@ -454,51 +462,6 @@ export enum MessageFlags { Loading = 1 << 7, } -/** - * https://discord.com/developers/docs/resources/channel#message-object-message-sticker-structure - */ -export interface APISticker { - /** - * ID of the sticker - */ - id: Snowflake; - /** - * ID of the pack the sticker is from - */ - pack_id: Snowflake; - /** - * Name of the sticker - */ - name: string; - /** - * Description of the sticker - */ - description: string; - /** - * A comma-separated list of tags for the sticker - */ - tags?: string; - /** - * Sticker asset hash - */ - asset: string; - /** - * Type of sticker format - * - * See https://discord.com/developers/docs/resources/channel#message-object-message-sticker-format-types - */ - format_type: StickerFormatType; -} - -/** - * https://discord.com/developers/docs/resources/channel#message-object-message-sticker-format-types - */ -export enum StickerFormatType { - PNG = 1, - APNG, - LOTTIE, -} - /** * https://discord.com/developers/docs/resources/channel#followed-channel-object */ diff --git a/deno/payloads/v8/guild.ts b/deno/payloads/v8/guild.ts index 774b8b6a..da652245 100644 --- a/deno/payloads/v8/guild.ts +++ b/deno/payloads/v8/guild.ts @@ -8,6 +8,7 @@ import type { APIEmoji } from './emoji.ts'; import type { GatewayPresenceUpdate, PresenceUpdateStatus } from './gateway.ts'; import type { APIRole } from './permissions.ts'; import type { APIStageInstance } from './stageInstance.ts'; +import type { APISticker } from './sticker.ts'; import type { APIUser } from './user.ts'; import type { GatewayVoiceState } from './voice.ts'; @@ -318,6 +319,12 @@ export interface APIGuild extends APIPartialGuild { * See https://discord.com/developers/docs/resources/stage-instance#stage-instance-object-stage-instance-structure */ stage_instances?: APIStageInstance[]; + /** + * Custom guild stickers + * + * See https://discord.com/developers/docs/resources/sticker#sticker-object + */ + stickers: APISticker[]; } /** diff --git a/deno/payloads/v8/mod.ts b/deno/payloads/v8/mod.ts index 7c98277c..7fea7fba 100644 --- a/deno/payloads/v8/mod.ts +++ b/deno/payloads/v8/mod.ts @@ -8,6 +8,7 @@ export * from './invite.ts'; export * from './oauth2.ts'; export * from './permissions.ts'; export * from './stageInstance.ts'; +export * from './sticker.ts'; export * from './teams.ts'; export * from './template.ts'; export * from './user.ts'; diff --git a/deno/payloads/v8/permissions.ts b/deno/payloads/v8/permissions.ts index ed1de1c2..6c01e193 100644 --- a/deno/payloads/v8/permissions.ts +++ b/deno/payloads/v8/permissions.ts @@ -42,7 +42,7 @@ export const PermissionFlagsBits = { ManageNicknames: 1n << 27n, ManageRoles: 1n << 28n, ManageWebhooks: 1n << 29n, - ManageEmojis: 1n << 30n, + ManageEmojisAndStickers: 1n << 30n, UseSlashCommands: 1n << 31n, RequestToSpeak: 1n << 32n, } as const; diff --git a/deno/payloads/v8/sticker.ts b/deno/payloads/v8/sticker.ts new file mode 100644 index 00000000..538cf93e --- /dev/null +++ b/deno/payloads/v8/sticker.ts @@ -0,0 +1,127 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/sticker + */ + +import type { Snowflake } from '../../globals.ts'; +import type { APIUser } from './user.ts'; + +/** + * https://discord.com/developers/docs/resources/sticker#sticker-object + */ +export interface APISticker { + /** + * ID of the sticker + */ + id: Snowflake; + /** + * For standard stickers, ID of the pack the sticker is from + */ + pack_id?: Snowflake; + /** + * Name of the sticker + */ + name: string; + /** + * Description of the sticker + */ + description: string | null; + /** + * For guild stickers, the Discord name of a unicode emoji representing the sticker's expression. for standard stickers, a comma-separated list of related expressions. + */ + tags: string; + /** + * Previously the sticker asset hash, now an empty string + * @deprecated + */ + asset: ''; + /** + * Type of sticker + * + * See https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-types + */ + type: StickerType; + /** + * Type of sticker format + * + * See https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-format-types + */ + format_type: StickerFormatType; + /** + * Whether this guild sticker can be used, may be false due to loss of Server Boosts + */ + available?: boolean; + /** + * ID of the guild that owns this sticker + */ + guild_id?: Snowflake; + /** + * The user that uploaded the guild sticker + */ + user?: APIUser; + /** + * The standard sticker's sort order within its pack + */ + sort_value?: number; +} + +/** + * https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-types + */ +export enum StickerType { + /** + * An official sticker in a pack, part of Nitro or in a removed purchasable pack + */ + Standard = 1, + /** + * A sticker uploaded to a Boosted guild for the guild's members + */ + Guild, +} + +/** + * https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-format-types + */ +export enum StickerFormatType { + PNG = 1, + APNG, + Lottie, +} + +/** + * https://discord.com/developers/docs/resources/sticker#sticker-item-object + */ +export type APIStickerItem = Pick; + +/** + * https://discord.com/developers/docs/resources/sticker#sticker-object + */ +export interface APIStickerPack { + /** + * ID of the sticker pack + */ + id: Snowflake; + /** + * The stickers in the pack + */ + stickers: APISticker[]; + /** + * Name of the sticker pack + */ + name: string; + /** + * ID of the pack's SKU + */ + sku_id: Snowflake; + /** + * ID of a sticker in the pack which is shown as the pack's icon + */ + cover_sticker_id?: Snowflake; + /** + * Description of the sticker pack + */ + description: string; + /** + * ID of the sticker pack's banner image + */ + banner_asset_id: Snowflake; +} diff --git a/deno/payloads/v9/auditLog.ts b/deno/payloads/v9/auditLog.ts index b43955f5..546d6cd7 100644 --- a/deno/payloads/v9/auditLog.ts +++ b/deno/payloads/v9/auditLog.ts @@ -3,7 +3,7 @@ */ import type { Snowflake } from '../../globals.ts'; -import type { APIOverwrite, ChannelType } from './channel.ts'; +import type { APIOverwrite } from './channel.ts'; import type { APIGuildIntegration, GuildDefaultMessageNotifications, @@ -13,6 +13,7 @@ import type { IntegrationExpireBehavior, } from './guild.ts'; import type { APIRole } from './permissions.ts'; +import type { StickerFormatType } from './sticker.ts'; import type { APIUser } from './user.ts'; import type { APIWebhook } from './webhook.ts'; import type { StageInstancePrivacyLevel } from './stageInstance.ts'; @@ -136,10 +137,13 @@ export enum AuditLogEvent { IntegrationCreate = 80, IntegrationUpdate, IntegrationDelete, - - StageInstanceCreate = 83, + StageInstanceCreate, StageInstanceUpdate, StageInstanceDelete, + + StickerCreate = 90, + StickerUpdate, + StickerDelete, } /** @@ -293,15 +297,20 @@ export type APIAuditLogChange = | APIAuditLogChangeKeyExpireBehavior | APIAuditLogChangeKeyExpireGracePeriod | APIAuditLogChangeKeyUserLimit - | APIAuditLogChangeKeyPrivacyLevel; + | APIAuditLogChangeKeyPrivacyLevel + | APIAuditLogChangeKeyTags + | APIAuditLogChangeKeyFormatType + | APIAuditLogChangeKeyAsset + | APIAuditLogChangeKeyAvailable + | APIAuditLogChangeKeyGuildID; /** - * Returned when a guild's name is changed + * Returned when an entity's name is changed */ export type APIAuditLogChangeKeyName = AuditLogChangeData<'name', string>; /** - * Returned when a guild's description is changed + * Returned when a guild's or sticker's description is changed */ export type APIAuditLogChangeKeyDescription = AuditLogChangeData<'description', string>; @@ -550,7 +559,7 @@ export type APIAuditLogChangeKeyID = AuditLogChangeData<'id', Snowflake>; /** * The type of entity created */ -export type APIAuditLogChangeKeyType = AuditLogChangeData<'type', ChannelType | string>; +export type APIAuditLogChangeKeyType = AuditLogChangeData<'type', number | string>; /** * Returned when an integration's enable_emoticons is changed @@ -577,6 +586,31 @@ export type APIAuditLogChangeKeyUserLimit = AuditLogChangeData<'user_limit', num */ export type APIAuditLogChangeKeyPrivacyLevel = AuditLogChangeData<'privacy_level', StageInstancePrivacyLevel>; +/** + * Returned when a sticker's related emoji is changed + */ +export type APIAuditLogChangeKeyTags = AuditLogChangeData<'tags', string>; + +/** + * Returned when a sticker's format_type is changed + */ +export type APIAuditLogChangeKeyFormatType = AuditLogChangeData<'format_type', StickerFormatType>; + +/** + * Empty string + */ +export type APIAuditLogChangeKeyAsset = AuditLogChangeData<'asset', ''>; + +/** + * Returned when a sticker's availability is changed + */ +export type APIAuditLogChangeKeyAvailable = AuditLogChangeData<'available', boolean>; + +/** + * Returned when a sticker's guild_id is changed + */ +export type APIAuditLogChangeKeyGuildID = AuditLogChangeData<'guild_id', Snowflake>; + interface AuditLogChangeData { key: K; /** diff --git a/deno/payloads/v9/channel.ts b/deno/payloads/v9/channel.ts index 8af9ce45..5a906725 100644 --- a/deno/payloads/v9/channel.ts +++ b/deno/payloads/v9/channel.ts @@ -6,8 +6,9 @@ import type { Permissions, Snowflake } from '../../globals.ts'; import type { APIPartialEmoji } from './emoji.ts'; import type { APIGuildMember } from './guild.ts'; import type { APIMessageInteraction } from './interactions.ts'; -import { APIApplication } from './oauth2.ts'; +import type { APIApplication } from './oauth2.ts'; import type { APIRole } from './permissions.ts'; +import type { APISticker, APIStickerItem } from './sticker.ts'; import type { APIUser } from './user.ts'; /** @@ -354,12 +355,6 @@ export interface APIMessage { * See https://en.wikipedia.org/wiki/Bit_field */ flags?: MessageFlags; - /** - * The stickers sent with the message (bots currently can only receive messages with stickers, not send) - * - * See https://discord.com/developers/docs/resources/channel#message-object-message-sticker-structure - */ - stickers?: APISticker[]; /** * The message associated with the `message_reference` * @@ -378,14 +373,27 @@ export interface APIMessage { * Sent if the message is a response to an Interaction */ interaction?: APIMessageInteraction; + /** + * Sent if a thread was started from this message + */ + thread?: APIChannel; /** * Sent if the message contains components like buttons, action rows, or other interactive components */ components?: APIActionRowComponent[]; /** - * Sent if a thread was started from this message + * Sent if the message contains stickers + * + * See https://discord.com/developers/docs/resources/sticker#sticker-item-object */ - thread?: APIChannel; + sticker_items?: APIStickerItem[]; + /** + * The stickers sent with the message + * + * See https://discord.com/developers/docs/resources/sticker#sticker-object + * @deprecated Use `sticker_items` instead + */ + stickers?: APISticker[]; } /** @@ -500,51 +508,6 @@ export enum MessageFlags { Loading = 1 << 7, } -/** - * https://discord.com/developers/docs/resources/channel#message-object-message-sticker-structure - */ -export interface APISticker { - /** - * ID of the sticker - */ - id: Snowflake; - /** - * ID of the pack the sticker is from - */ - pack_id: Snowflake; - /** - * Name of the sticker - */ - name: string; - /** - * Description of the sticker - */ - description: string; - /** - * A comma-separated list of tags for the sticker - */ - tags?: string; - /** - * Sticker asset hash - */ - asset: string; - /** - * Type of sticker format - * - * See https://discord.com/developers/docs/resources/channel#message-object-message-sticker-format-types - */ - format_type: StickerFormatType; -} - -/** - * https://discord.com/developers/docs/resources/channel#message-object-message-sticker-format-types - */ -export enum StickerFormatType { - PNG = 1, - APNG, - LOTTIE, -} - /** * https://discord.com/developers/docs/resources/channel#followed-channel-object */ diff --git a/deno/payloads/v9/guild.ts b/deno/payloads/v9/guild.ts index 483d825a..232c8b59 100644 --- a/deno/payloads/v9/guild.ts +++ b/deno/payloads/v9/guild.ts @@ -8,6 +8,7 @@ import type { APIEmoji } from './emoji.ts'; import type { GatewayPresenceUpdate, PresenceUpdateStatus } from './gateway.ts'; import type { APIRole } from './permissions.ts'; import type { APIStageInstance } from './stageInstance.ts'; +import type { APISticker } from './sticker.ts'; import type { APIUser } from './user.ts'; import type { GatewayVoiceState } from './voice.ts'; @@ -326,6 +327,12 @@ export interface APIGuild extends APIPartialGuild { * See https://discord.com/developers/docs/resources/stage-instance#stage-instance-object-stage-instance-structure */ stage_instances?: APIStageInstance[]; + /** + * Custom guild stickers + * + * See https://discord.com/developers/docs/resources/sticker#sticker-object + */ + stickers: APISticker[]; } /** diff --git a/deno/payloads/v9/mod.ts b/deno/payloads/v9/mod.ts index 7c98277c..7fea7fba 100644 --- a/deno/payloads/v9/mod.ts +++ b/deno/payloads/v9/mod.ts @@ -8,6 +8,7 @@ export * from './invite.ts'; export * from './oauth2.ts'; export * from './permissions.ts'; export * from './stageInstance.ts'; +export * from './sticker.ts'; export * from './teams.ts'; export * from './template.ts'; export * from './user.ts'; diff --git a/deno/payloads/v9/permissions.ts b/deno/payloads/v9/permissions.ts index 6823efd5..e6708360 100644 --- a/deno/payloads/v9/permissions.ts +++ b/deno/payloads/v9/permissions.ts @@ -42,7 +42,7 @@ export const PermissionFlagsBits = { ManageNicknames: 1n << 27n, ManageRoles: 1n << 28n, ManageWebhooks: 1n << 29n, - ManageEmojis: 1n << 30n, + ManageEmojisAndStickers: 1n << 30n, UseSlashCommands: 1n << 31n, RequestToSpeak: 1n << 32n, ManageThreads: 1n << 34n, diff --git a/deno/payloads/v9/sticker.ts b/deno/payloads/v9/sticker.ts new file mode 100644 index 00000000..538cf93e --- /dev/null +++ b/deno/payloads/v9/sticker.ts @@ -0,0 +1,127 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/sticker + */ + +import type { Snowflake } from '../../globals.ts'; +import type { APIUser } from './user.ts'; + +/** + * https://discord.com/developers/docs/resources/sticker#sticker-object + */ +export interface APISticker { + /** + * ID of the sticker + */ + id: Snowflake; + /** + * For standard stickers, ID of the pack the sticker is from + */ + pack_id?: Snowflake; + /** + * Name of the sticker + */ + name: string; + /** + * Description of the sticker + */ + description: string | null; + /** + * For guild stickers, the Discord name of a unicode emoji representing the sticker's expression. for standard stickers, a comma-separated list of related expressions. + */ + tags: string; + /** + * Previously the sticker asset hash, now an empty string + * @deprecated + */ + asset: ''; + /** + * Type of sticker + * + * See https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-types + */ + type: StickerType; + /** + * Type of sticker format + * + * See https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-format-types + */ + format_type: StickerFormatType; + /** + * Whether this guild sticker can be used, may be false due to loss of Server Boosts + */ + available?: boolean; + /** + * ID of the guild that owns this sticker + */ + guild_id?: Snowflake; + /** + * The user that uploaded the guild sticker + */ + user?: APIUser; + /** + * The standard sticker's sort order within its pack + */ + sort_value?: number; +} + +/** + * https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-types + */ +export enum StickerType { + /** + * An official sticker in a pack, part of Nitro or in a removed purchasable pack + */ + Standard = 1, + /** + * A sticker uploaded to a Boosted guild for the guild's members + */ + Guild, +} + +/** + * https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-format-types + */ +export enum StickerFormatType { + PNG = 1, + APNG, + Lottie, +} + +/** + * https://discord.com/developers/docs/resources/sticker#sticker-item-object + */ +export type APIStickerItem = Pick; + +/** + * https://discord.com/developers/docs/resources/sticker#sticker-object + */ +export interface APIStickerPack { + /** + * ID of the sticker pack + */ + id: Snowflake; + /** + * The stickers in the pack + */ + stickers: APISticker[]; + /** + * Name of the sticker pack + */ + name: string; + /** + * ID of the pack's SKU + */ + sku_id: Snowflake; + /** + * ID of a sticker in the pack which is shown as the pack's icon + */ + cover_sticker_id?: Snowflake; + /** + * Description of the sticker pack + */ + description: string; + /** + * ID of the sticker pack's banner image + */ + banner_asset_id: Snowflake; +} diff --git a/deno/rest/common.ts b/deno/rest/common.ts index a2af6bde..9e613a04 100644 --- a/deno/rest/common.ts +++ b/deno/rest/common.ts @@ -32,6 +32,8 @@ export enum RESTJSONErrorCodes { UnknownGuildTemplate = 10057, + UnknownSticker = 10060, + UnknownInteraction = 10062, UnknownApplicationCommand, @@ -61,6 +63,8 @@ export enum RESTJSONErrorCodes { MaximumThreadParticipants = 30033, + MaximumNumberOfStickersReached = 30039, + Unauthorized = 40001, VerifyYourAccount, @@ -103,6 +107,9 @@ export enum RESTJSONErrorCodes { InvalidAPIVersion = 50041, + FileUploadedExceedsMaximumSize = 50045, + InvalidFileUploaded, + CannotDeleteChannelRequiredForCommunityGuilds = 50074, InvalidStickerSent = 50081, @@ -120,5 +127,9 @@ export enum RESTJSONErrorCodes { ThreadAlreadyCreatedForMessage = 160004, ThreadLocked, MaximumActiveThreads, - MaximumActiveAnnoucementThreads, + MaximumActiveAnnouncementThreads, + + InvalidJSONForUploadedLottieFile = 170001, + + LottieAnimationMaximumDimensionsExceeded = 170005, } diff --git a/deno/rest/v8/channel.ts b/deno/rest/v8/channel.ts index 9d782e5d..385fbf81 100644 --- a/deno/rest/v8/channel.ts +++ b/deno/rest/v8/channel.ts @@ -200,6 +200,12 @@ export interface RESTPostAPIChannelMessageJSONBody { * See https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure */ message_reference?: APIMessageReferenceSend; + /** + * IDs of up to 3 stickers in the server to send in the message + * + * See https://discord.com/developers/docs/resources/sticker#sticker-object + */ + sticker_ids?: [Snowflake] | [Snowflake, Snowflake] | [Snowflake, Snowflake, Snowflake]; } /** diff --git a/deno/rest/v8/mod.ts b/deno/rest/v8/mod.ts index deeb314f..53892ef5 100644 --- a/deno/rest/v8/mod.ts +++ b/deno/rest/v8/mod.ts @@ -11,6 +11,7 @@ export * from './interactions.ts'; export * from './invite.ts'; export * from './oauth2.ts'; export * from './stageInstance.ts'; +export * from './sticker.ts'; export * from './template.ts'; export * from './user.ts'; export * from './voice.ts'; @@ -678,6 +679,41 @@ export const Routes = { stageInstance(channelID: Snowflake) { return `/stage-instances/${channelID}` as const; }, + + /** + * Route for: + * - GET `/stickers/{sticker.id}` + */ + sticker(stickerID: Snowflake) { + return `/stickers/${stickerID}` as const; + }, + + /** + * Route for: + * - GET `/sticker-packs` + */ + nitroStickerPacks() { + return '/sticker-packs' as const; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/stickers` + * - POST `/guilds/{guild.id}/stickers` + */ + guildStickers(guildID: Snowflake) { + return `/guilds/${guildID}/stickers` as const; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/stickers/{sticker.id}` + * - PATCH `/guilds/{guild.id}/stickers/{sticker.id}` + * - DELETE `/guilds/{guild.id}/stickers/{sticker.id}` + */ + guildSticker(guildID: Snowflake, stickerID: Snowflake) { + return `/guilds/${guildID}/stickers/${stickerID}` as const; + }, }; export const RouteBases = { diff --git a/deno/rest/v8/sticker.ts b/deno/rest/v8/sticker.ts new file mode 100644 index 00000000..38a79113 --- /dev/null +++ b/deno/rest/v8/sticker.ts @@ -0,0 +1,51 @@ +import type { APISticker, APIStickerPack } from '../../payloads/v8/mod.ts'; + +export type RESTGetAPIStickerResult = APISticker; + +export interface RESTGetNitroStickerPacksResult { + sticker_packs: APIStickerPack[]; +} + +export type RESTGetAPIGuildStickersResult = APISticker[]; + +export type RESTGetAPIGuildStickerResult = APISticker; + +export interface RESTPostAPIGuildStickerFormDataBody { + /** + * Name of the sticker (2-30 characters) + */ + name: string; + /** + * Description of the sticker (empty or 2-100 characters) + */ + description: string; + /** + * The Discord name of a unicode emoji representing the sticker's expression (2-200 characters) + */ + tags: string; + /** + * The sticker file to upload, must be a PNG, APNG, or Lottie JSON file, max 500 KB + */ + file: unknown; +} + +export type RESTPostAPIGuildStickerResult = APISticker; + +export interface RESTPatchAPIGuildStickerJSONBody { + /** + * Name of the sticker (2-30 characters) + */ + name?: string; + /** + * Description of the sticker (2-100 characters) + */ + description?: string | null; + /** + * The Discord name of a unicode emoji representing the sticker's expression (2-200 characters) + */ + tags?: string; +} + +export type RESTPatchAPIGuildStickerResult = APISticker; + +export type RESTDeleteAPIGuildStickerResult = never; diff --git a/deno/rest/v9/channel.ts b/deno/rest/v9/channel.ts index bc070aca..02ebc9ef 100644 --- a/deno/rest/v9/channel.ts +++ b/deno/rest/v9/channel.ts @@ -228,6 +228,12 @@ export interface RESTPostAPIChannelMessageJSONBody { * See https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure */ message_reference?: APIMessageReferenceSend; + /** + * IDs of up to 3 stickers in the server to send in the message + * + * See https://discord.com/developers/docs/resources/sticker#sticker-object + */ + sticker_ids?: [Snowflake] | [Snowflake, Snowflake] | [Snowflake, Snowflake, Snowflake]; } /** diff --git a/deno/rest/v9/mod.ts b/deno/rest/v9/mod.ts index 7087933a..2f273ba2 100644 --- a/deno/rest/v9/mod.ts +++ b/deno/rest/v9/mod.ts @@ -11,6 +11,7 @@ export * from './interactions.ts'; export * from './invite.ts'; export * from './oauth2.ts'; export * from './stageInstance.ts'; +export * from './sticker.ts'; export * from './template.ts'; export * from './user.ts'; export * from './voice.ts'; @@ -736,6 +737,41 @@ export const Routes = { stageInstance(channelID: Snowflake) { return `/stage-instances/${channelID}` as const; }, + + /** + * Route for: + * - GET `/stickers/{sticker.id}` + */ + sticker(stickerID: Snowflake) { + return `/stickers/${stickerID}` as const; + }, + + /** + * Route for: + * - GET `/sticker-packs` + */ + nitroStickerPacks() { + return '/sticker-packs' as const; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/stickers` + * - POST `/guilds/{guild.id}/stickers` + */ + guildStickers(guildID: Snowflake) { + return `/guilds/${guildID}/stickers` as const; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/stickers/{sticker.id}` + * - PATCH `/guilds/{guild.id}/stickers/{sticker.id}` + * - DELETE `/guilds/{guild.id}/stickers/{sticker.id}` + */ + guildSticker(guildID: Snowflake, stickerID: Snowflake) { + return `/guilds/${guildID}/stickers/${stickerID}` as const; + }, }; export const RouteBases = { diff --git a/deno/rest/v9/sticker.ts b/deno/rest/v9/sticker.ts new file mode 100644 index 00000000..3b7458b4 --- /dev/null +++ b/deno/rest/v9/sticker.ts @@ -0,0 +1,51 @@ +import type { APISticker, APIStickerPack } from '../../payloads/v9/mod.ts'; + +export type RESTGetAPIStickerResult = APISticker; + +export interface RESTGetNitroStickerPacksResult { + sticker_packs: APIStickerPack[]; +} + +export type RESTGetAPIGuildStickersResult = APISticker[]; + +export type RESTGetAPIGuildStickerResult = APISticker; + +export interface RESTPostAPIGuildStickerFormDataBody { + /** + * Name of the sticker (2-30 characters) + */ + name: string; + /** + * Description of the sticker (empty or 2-100 characters) + */ + description: string; + /** + * The Discord name of a unicode emoji representing the sticker's expression (2-200 characters) + */ + tags: string; + /** + * The sticker file to upload, must be a PNG, APNG, or Lottie JSON file, max 500 KB + */ + file: unknown; +} + +export type RESTPostAPIGuildStickerResult = APISticker; + +export interface RESTPatchAPIGuildStickerJSONBody { + /** + * Name of the sticker (2-30 characters) + */ + name?: string; + /** + * Description of the sticker (2-100 characters) + */ + description?: string | null; + /** + * The Discord name of a unicode emoji representing the sticker's expression (2-200 characters) + */ + tags?: string; +} + +export type RESTPatchAPIGuildStickerResult = APISticker; + +export type RESTDeleteAPIGuildStickerResult = never; diff --git a/gateway/v8.ts b/gateway/v8.ts index c9ba4c25..192aefb0 100644 --- a/gateway/v8.ts +++ b/gateway/v8.ts @@ -16,6 +16,7 @@ import type { APIMessageComponentInteraction, APIRole, APIStageInstance, + APISticker, APIUnavailableGuild, APIUser, GatewayActivity, @@ -170,7 +171,7 @@ export const enum GatewayIntentBits { Guilds = 1 << 0, GuildMembers = 1 << 1, GuildBans = 1 << 2, - GuildEmojis = 1 << 3, + GuildEmojisAndStickers = 1 << 3, GuildIntegrations = 1 << 4, GuildWebhooks = 1 << 5, GuildInvites = 1 << 6, @@ -208,6 +209,7 @@ export const enum GatewayDispatchEvents { GuildRoleCreate = 'GUILD_ROLE_CREATE', GuildRoleDelete = 'GUILD_ROLE_DELETE', GuildRoleUpdate = 'GUILD_ROLE_UPDATE', + GuildStickersUpdate = 'GUILD_STICKERS_UPDATE', GuildUpdate = 'GUILD_UPDATE', IntegrationCreate = 'INTEGRATION_CREATE', IntegrationDelete = 'INTEGRATION_DELETE', @@ -266,6 +268,7 @@ export type GatewayDispatchPayload = | GatewayGuildModifyDispatch | GatewayGuildRoleDeleteDispatch | GatewayGuildRoleModifyDispatch + | GatewayGuildStickersUpdateDispatch | GatewayIntegrationCreateDispatch | GatewayIntegrationDeleteDispatch | GatewayIntegrationUpdateDispatch @@ -638,6 +641,30 @@ export interface GatewayGuildEmojisUpdateDispatchData { emojis: APIEmoji[]; } +/** + * https://discord.com/developers/docs/topics/gateway#guild-stickers-update + */ +export type GatewayGuildStickersUpdateDispatch = DataPayload< + GatewayDispatchEvents.GuildStickersUpdate, + GatewayGuildStickersUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-stickers-update + */ +export interface GatewayGuildStickersUpdateDispatchData { + /** + * ID of the guild + */ + guild_id: Snowflake; + /** + * Array of stickers + * + * See https://discord.com/developers/docs/resources/sticker#sticker-object + */ + stickers: APISticker[]; +} + /** * https://discord.com/developers/docs/topics/gateway#guild-integrations-update */ diff --git a/gateway/v9.ts b/gateway/v9.ts index 8ebefa56..2a354ba3 100644 --- a/gateway/v9.ts +++ b/gateway/v9.ts @@ -16,6 +16,7 @@ import type { APIMessageComponentInteraction, APIRole, APIStageInstance, + APISticker, APIThreadMember, APIUnavailableGuild, APIUser, @@ -173,7 +174,7 @@ export const enum GatewayIntentBits { Guilds = 1 << 0, GuildMembers = 1 << 1, GuildBans = 1 << 2, - GuildEmojis = 1 << 3, + GuildEmojisAndStickers = 1 << 3, GuildIntegrations = 1 << 4, GuildWebhooks = 1 << 5, GuildInvites = 1 << 6, @@ -211,6 +212,7 @@ export const enum GatewayDispatchEvents { GuildRoleCreate = 'GUILD_ROLE_CREATE', GuildRoleDelete = 'GUILD_ROLE_DELETE', GuildRoleUpdate = 'GUILD_ROLE_UPDATE', + GuildStickersUpdate = 'GUILD_STICKERS_UPDATE', GuildUpdate = 'GUILD_UPDATE', IntegrationCreate = 'INTEGRATION_CREATE', IntegrationDelete = 'INTEGRATION_DELETE', @@ -275,6 +277,7 @@ export type GatewayDispatchPayload = | GatewayGuildModifyDispatch | GatewayGuildRoleDeleteDispatch | GatewayGuildRoleModifyDispatch + | GatewayGuildStickersUpdateDispatch | GatewayIntegrationCreateDispatch | GatewayIntegrationDeleteDispatch | GatewayIntegrationUpdateDispatch @@ -648,6 +651,30 @@ export interface GatewayGuildEmojisUpdateDispatchData { emojis: APIEmoji[]; } +/** + * https://discord.com/developers/docs/topics/gateway#guild-stickers-update + */ +export type GatewayGuildStickersUpdateDispatch = DataPayload< + GatewayDispatchEvents.GuildStickersUpdate, + GatewayGuildStickersUpdateDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway#guild-stickers-update + */ +export interface GatewayGuildStickersUpdateDispatchData { + /** + * ID of the guild + */ + guild_id: Snowflake; + /** + * Array of stickers + * + * See https://discord.com/developers/docs/resources/sticker#sticker-object + */ + stickers: APISticker[]; +} + /** * https://discord.com/developers/docs/topics/gateway#guild-integrations-update */ diff --git a/payloads/v8/auditLog.ts b/payloads/v8/auditLog.ts index 9f987667..45362cc8 100644 --- a/payloads/v8/auditLog.ts +++ b/payloads/v8/auditLog.ts @@ -3,7 +3,7 @@ */ import type { Snowflake } from '../../globals'; -import type { APIOverwrite, ChannelType } from './channel'; +import type { APIOverwrite } from './channel'; import type { APIGuildIntegration, GuildDefaultMessageNotifications, @@ -13,6 +13,7 @@ import type { IntegrationExpireBehavior, } from './guild'; import type { APIRole } from './permissions'; +import type { StickerFormatType } from './sticker'; import type { APIUser } from './user'; import type { APIWebhook } from './webhook'; import type { StageInstancePrivacyLevel } from './stageInstance'; @@ -136,10 +137,13 @@ export const enum AuditLogEvent { IntegrationCreate = 80, IntegrationUpdate, IntegrationDelete, - - StageInstanceCreate = 83, + StageInstanceCreate, StageInstanceUpdate, StageInstanceDelete, + + StickerCreate = 90, + StickerUpdate, + StickerDelete, } /** @@ -293,15 +297,20 @@ export type APIAuditLogChange = | APIAuditLogChangeKeyExpireBehavior | APIAuditLogChangeKeyExpireGracePeriod | APIAuditLogChangeKeyUserLimit - | APIAuditLogChangeKeyPrivacyLevel; + | APIAuditLogChangeKeyPrivacyLevel + | APIAuditLogChangeKeyTags + | APIAuditLogChangeKeyFormatType + | APIAuditLogChangeKeyAsset + | APIAuditLogChangeKeyAvailable + | APIAuditLogChangeKeyGuildID; /** - * Returned when a guild's name is changed + * Returned when an entity's name is changed */ export type APIAuditLogChangeKeyName = AuditLogChangeData<'name', string>; /** - * Returned when a guild's description is changed + * Returned when a guild's or sticker's description is changed */ export type APIAuditLogChangeKeyDescription = AuditLogChangeData<'description', string>; @@ -550,7 +559,7 @@ export type APIAuditLogChangeKeyID = AuditLogChangeData<'id', Snowflake>; /** * The type of entity created */ -export type APIAuditLogChangeKeyType = AuditLogChangeData<'type', ChannelType | string>; +export type APIAuditLogChangeKeyType = AuditLogChangeData<'type', number | string>; /** * Returned when an integration's enable_emoticons is changed @@ -577,6 +586,31 @@ export type APIAuditLogChangeKeyUserLimit = AuditLogChangeData<'user_limit', num */ export type APIAuditLogChangeKeyPrivacyLevel = AuditLogChangeData<'privacy_level', StageInstancePrivacyLevel>; +/** + * Returned when a sticker's related emoji is changed + */ +export type APIAuditLogChangeKeyTags = AuditLogChangeData<'tags', string>; + +/** + * Returned when a sticker's format_type is changed + */ +export type APIAuditLogChangeKeyFormatType = AuditLogChangeData<'format_type', StickerFormatType>; + +/** + * Empty string + */ +export type APIAuditLogChangeKeyAsset = AuditLogChangeData<'asset', ''>; + +/** + * Returned when a sticker's availability is changed + */ +export type APIAuditLogChangeKeyAvailable = AuditLogChangeData<'available', boolean>; + +/** + * Returned when a sticker's guild_id is changed + */ +export type APIAuditLogChangeKeyGuildID = AuditLogChangeData<'guild_id', Snowflake>; + interface AuditLogChangeData { key: K; /** diff --git a/payloads/v8/channel.ts b/payloads/v8/channel.ts index c7581eef..d977374d 100644 --- a/payloads/v8/channel.ts +++ b/payloads/v8/channel.ts @@ -6,8 +6,9 @@ import type { Permissions, Snowflake } from '../../globals'; import type { APIPartialEmoji } from './emoji'; import type { APIGuildMember } from './guild'; import type { APIMessageInteraction } from './interactions'; -import { APIApplication } from './oauth2'; +import type { APIApplication } from './oauth2'; import type { APIRole } from './permissions'; +import type { APISticker, APIStickerItem } from './sticker'; import type { APIUser } from './user'; /** @@ -318,12 +319,6 @@ export interface APIMessage { * See https://en.wikipedia.org/wiki/Bit_field */ flags?: MessageFlags; - /** - * The stickers sent with the message (bots currently can only receive messages with stickers, not send) - * - * See https://discord.com/developers/docs/resources/channel#message-object-message-sticker-structure - */ - stickers?: APISticker[]; /** * The message associated with the `message_reference` * @@ -346,6 +341,19 @@ export interface APIMessage { * Sent if the message contains components like buttons, action rows, or other interactive components */ components?: APIActionRowComponent[]; + /** + * Sent if the message contains stickers + * + * See https://discord.com/developers/docs/resources/sticker#sticker-item-object + */ + sticker_items?: APIStickerItem[]; + /** + * The stickers sent with the message + * + * See https://discord.com/developers/docs/resources/sticker#sticker-object + * @deprecated Use `sticker_items` instead + */ + stickers?: APISticker[]; } /** @@ -454,51 +462,6 @@ export const enum MessageFlags { Loading = 1 << 7, } -/** - * https://discord.com/developers/docs/resources/channel#message-object-message-sticker-structure - */ -export interface APISticker { - /** - * ID of the sticker - */ - id: Snowflake; - /** - * ID of the pack the sticker is from - */ - pack_id: Snowflake; - /** - * Name of the sticker - */ - name: string; - /** - * Description of the sticker - */ - description: string; - /** - * A comma-separated list of tags for the sticker - */ - tags?: string; - /** - * Sticker asset hash - */ - asset: string; - /** - * Type of sticker format - * - * See https://discord.com/developers/docs/resources/channel#message-object-message-sticker-format-types - */ - format_type: StickerFormatType; -} - -/** - * https://discord.com/developers/docs/resources/channel#message-object-message-sticker-format-types - */ -export const enum StickerFormatType { - PNG = 1, - APNG, - LOTTIE, -} - /** * https://discord.com/developers/docs/resources/channel#followed-channel-object */ diff --git a/payloads/v8/guild.ts b/payloads/v8/guild.ts index 689180bb..53824ac3 100644 --- a/payloads/v8/guild.ts +++ b/payloads/v8/guild.ts @@ -8,6 +8,7 @@ import type { APIEmoji } from './emoji'; import type { GatewayPresenceUpdate, PresenceUpdateStatus } from './gateway'; import type { APIRole } from './permissions'; import type { APIStageInstance } from './stageInstance'; +import type { APISticker } from './sticker'; import type { APIUser } from './user'; import type { GatewayVoiceState } from './voice'; @@ -318,6 +319,12 @@ export interface APIGuild extends APIPartialGuild { * See https://discord.com/developers/docs/resources/stage-instance#stage-instance-object-stage-instance-structure */ stage_instances?: APIStageInstance[]; + /** + * Custom guild stickers + * + * See https://discord.com/developers/docs/resources/sticker#sticker-object + */ + stickers: APISticker[]; } /** diff --git a/payloads/v8/index.ts b/payloads/v8/index.ts index 5aa2547f..5adfe5d8 100644 --- a/payloads/v8/index.ts +++ b/payloads/v8/index.ts @@ -8,6 +8,7 @@ export * from './invite'; export * from './oauth2'; export * from './permissions'; export * from './stageInstance'; +export * from './sticker'; export * from './teams'; export * from './template'; export * from './user'; diff --git a/payloads/v8/permissions.ts b/payloads/v8/permissions.ts index 44618540..33a4b178 100644 --- a/payloads/v8/permissions.ts +++ b/payloads/v8/permissions.ts @@ -42,7 +42,7 @@ export const PermissionFlagsBits = { ManageNicknames: 1n << 27n, ManageRoles: 1n << 28n, ManageWebhooks: 1n << 29n, - ManageEmojis: 1n << 30n, + ManageEmojisAndStickers: 1n << 30n, UseSlashCommands: 1n << 31n, RequestToSpeak: 1n << 32n, } as const; diff --git a/payloads/v8/sticker.ts b/payloads/v8/sticker.ts new file mode 100644 index 00000000..1582dbf0 --- /dev/null +++ b/payloads/v8/sticker.ts @@ -0,0 +1,127 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/sticker + */ + +import type { Snowflake } from '../../globals'; +import type { APIUser } from './user'; + +/** + * https://discord.com/developers/docs/resources/sticker#sticker-object + */ +export interface APISticker { + /** + * ID of the sticker + */ + id: Snowflake; + /** + * For standard stickers, ID of the pack the sticker is from + */ + pack_id?: Snowflake; + /** + * Name of the sticker + */ + name: string; + /** + * Description of the sticker + */ + description: string | null; + /** + * For guild stickers, the Discord name of a unicode emoji representing the sticker's expression. for standard stickers, a comma-separated list of related expressions. + */ + tags: string; + /** + * Previously the sticker asset hash, now an empty string + * @deprecated + */ + asset: ''; + /** + * Type of sticker + * + * See https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-types + */ + type: StickerType; + /** + * Type of sticker format + * + * See https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-format-types + */ + format_type: StickerFormatType; + /** + * Whether this guild sticker can be used, may be false due to loss of Server Boosts + */ + available?: boolean; + /** + * ID of the guild that owns this sticker + */ + guild_id?: Snowflake; + /** + * The user that uploaded the guild sticker + */ + user?: APIUser; + /** + * The standard sticker's sort order within its pack + */ + sort_value?: number; +} + +/** + * https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-types + */ +export const enum StickerType { + /** + * An official sticker in a pack, part of Nitro or in a removed purchasable pack + */ + Standard = 1, + /** + * A sticker uploaded to a Boosted guild for the guild's members + */ + Guild, +} + +/** + * https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-format-types + */ +export const enum StickerFormatType { + PNG = 1, + APNG, + Lottie, +} + +/** + * https://discord.com/developers/docs/resources/sticker#sticker-item-object + */ +export type APIStickerItem = Pick; + +/** + * https://discord.com/developers/docs/resources/sticker#sticker-object + */ +export interface APIStickerPack { + /** + * ID of the sticker pack + */ + id: Snowflake; + /** + * The stickers in the pack + */ + stickers: APISticker[]; + /** + * Name of the sticker pack + */ + name: string; + /** + * ID of the pack's SKU + */ + sku_id: Snowflake; + /** + * ID of a sticker in the pack which is shown as the pack's icon + */ + cover_sticker_id?: Snowflake; + /** + * Description of the sticker pack + */ + description: string; + /** + * ID of the sticker pack's banner image + */ + banner_asset_id: Snowflake; +} diff --git a/payloads/v9/auditLog.ts b/payloads/v9/auditLog.ts index 9f987667..45362cc8 100644 --- a/payloads/v9/auditLog.ts +++ b/payloads/v9/auditLog.ts @@ -3,7 +3,7 @@ */ import type { Snowflake } from '../../globals'; -import type { APIOverwrite, ChannelType } from './channel'; +import type { APIOverwrite } from './channel'; import type { APIGuildIntegration, GuildDefaultMessageNotifications, @@ -13,6 +13,7 @@ import type { IntegrationExpireBehavior, } from './guild'; import type { APIRole } from './permissions'; +import type { StickerFormatType } from './sticker'; import type { APIUser } from './user'; import type { APIWebhook } from './webhook'; import type { StageInstancePrivacyLevel } from './stageInstance'; @@ -136,10 +137,13 @@ export const enum AuditLogEvent { IntegrationCreate = 80, IntegrationUpdate, IntegrationDelete, - - StageInstanceCreate = 83, + StageInstanceCreate, StageInstanceUpdate, StageInstanceDelete, + + StickerCreate = 90, + StickerUpdate, + StickerDelete, } /** @@ -293,15 +297,20 @@ export type APIAuditLogChange = | APIAuditLogChangeKeyExpireBehavior | APIAuditLogChangeKeyExpireGracePeriod | APIAuditLogChangeKeyUserLimit - | APIAuditLogChangeKeyPrivacyLevel; + | APIAuditLogChangeKeyPrivacyLevel + | APIAuditLogChangeKeyTags + | APIAuditLogChangeKeyFormatType + | APIAuditLogChangeKeyAsset + | APIAuditLogChangeKeyAvailable + | APIAuditLogChangeKeyGuildID; /** - * Returned when a guild's name is changed + * Returned when an entity's name is changed */ export type APIAuditLogChangeKeyName = AuditLogChangeData<'name', string>; /** - * Returned when a guild's description is changed + * Returned when a guild's or sticker's description is changed */ export type APIAuditLogChangeKeyDescription = AuditLogChangeData<'description', string>; @@ -550,7 +559,7 @@ export type APIAuditLogChangeKeyID = AuditLogChangeData<'id', Snowflake>; /** * The type of entity created */ -export type APIAuditLogChangeKeyType = AuditLogChangeData<'type', ChannelType | string>; +export type APIAuditLogChangeKeyType = AuditLogChangeData<'type', number | string>; /** * Returned when an integration's enable_emoticons is changed @@ -577,6 +586,31 @@ export type APIAuditLogChangeKeyUserLimit = AuditLogChangeData<'user_limit', num */ export type APIAuditLogChangeKeyPrivacyLevel = AuditLogChangeData<'privacy_level', StageInstancePrivacyLevel>; +/** + * Returned when a sticker's related emoji is changed + */ +export type APIAuditLogChangeKeyTags = AuditLogChangeData<'tags', string>; + +/** + * Returned when a sticker's format_type is changed + */ +export type APIAuditLogChangeKeyFormatType = AuditLogChangeData<'format_type', StickerFormatType>; + +/** + * Empty string + */ +export type APIAuditLogChangeKeyAsset = AuditLogChangeData<'asset', ''>; + +/** + * Returned when a sticker's availability is changed + */ +export type APIAuditLogChangeKeyAvailable = AuditLogChangeData<'available', boolean>; + +/** + * Returned when a sticker's guild_id is changed + */ +export type APIAuditLogChangeKeyGuildID = AuditLogChangeData<'guild_id', Snowflake>; + interface AuditLogChangeData { key: K; /** diff --git a/payloads/v9/channel.ts b/payloads/v9/channel.ts index 800f5aa7..64991b9f 100644 --- a/payloads/v9/channel.ts +++ b/payloads/v9/channel.ts @@ -6,8 +6,9 @@ import type { Permissions, Snowflake } from '../../globals'; import type { APIPartialEmoji } from './emoji'; import type { APIGuildMember } from './guild'; import type { APIMessageInteraction } from './interactions'; -import { APIApplication } from './oauth2'; +import type { APIApplication } from './oauth2'; import type { APIRole } from './permissions'; +import type { APISticker, APIStickerItem } from './sticker'; import type { APIUser } from './user'; /** @@ -354,12 +355,6 @@ export interface APIMessage { * See https://en.wikipedia.org/wiki/Bit_field */ flags?: MessageFlags; - /** - * The stickers sent with the message (bots currently can only receive messages with stickers, not send) - * - * See https://discord.com/developers/docs/resources/channel#message-object-message-sticker-structure - */ - stickers?: APISticker[]; /** * The message associated with the `message_reference` * @@ -378,14 +373,27 @@ export interface APIMessage { * Sent if the message is a response to an Interaction */ interaction?: APIMessageInteraction; + /** + * Sent if a thread was started from this message + */ + thread?: APIChannel; /** * Sent if the message contains components like buttons, action rows, or other interactive components */ components?: APIActionRowComponent[]; /** - * Sent if a thread was started from this message + * Sent if the message contains stickers + * + * See https://discord.com/developers/docs/resources/sticker#sticker-item-object */ - thread?: APIChannel; + sticker_items?: APIStickerItem[]; + /** + * The stickers sent with the message + * + * See https://discord.com/developers/docs/resources/sticker#sticker-object + * @deprecated Use `sticker_items` instead + */ + stickers?: APISticker[]; } /** @@ -500,51 +508,6 @@ export const enum MessageFlags { Loading = 1 << 7, } -/** - * https://discord.com/developers/docs/resources/channel#message-object-message-sticker-structure - */ -export interface APISticker { - /** - * ID of the sticker - */ - id: Snowflake; - /** - * ID of the pack the sticker is from - */ - pack_id: Snowflake; - /** - * Name of the sticker - */ - name: string; - /** - * Description of the sticker - */ - description: string; - /** - * A comma-separated list of tags for the sticker - */ - tags?: string; - /** - * Sticker asset hash - */ - asset: string; - /** - * Type of sticker format - * - * See https://discord.com/developers/docs/resources/channel#message-object-message-sticker-format-types - */ - format_type: StickerFormatType; -} - -/** - * https://discord.com/developers/docs/resources/channel#message-object-message-sticker-format-types - */ -export const enum StickerFormatType { - PNG = 1, - APNG, - LOTTIE, -} - /** * https://discord.com/developers/docs/resources/channel#followed-channel-object */ diff --git a/payloads/v9/guild.ts b/payloads/v9/guild.ts index 74d6b7ce..1fab1231 100644 --- a/payloads/v9/guild.ts +++ b/payloads/v9/guild.ts @@ -8,6 +8,7 @@ import type { APIEmoji } from './emoji'; import type { GatewayPresenceUpdate, PresenceUpdateStatus } from './gateway'; import type { APIRole } from './permissions'; import type { APIStageInstance } from './stageInstance'; +import type { APISticker } from './sticker'; import type { APIUser } from './user'; import type { GatewayVoiceState } from './voice'; @@ -326,6 +327,12 @@ export interface APIGuild extends APIPartialGuild { * See https://discord.com/developers/docs/resources/stage-instance#stage-instance-object-stage-instance-structure */ stage_instances?: APIStageInstance[]; + /** + * Custom guild stickers + * + * See https://discord.com/developers/docs/resources/sticker#sticker-object + */ + stickers: APISticker[]; } /** diff --git a/payloads/v9/index.ts b/payloads/v9/index.ts index 5aa2547f..5adfe5d8 100644 --- a/payloads/v9/index.ts +++ b/payloads/v9/index.ts @@ -8,6 +8,7 @@ export * from './invite'; export * from './oauth2'; export * from './permissions'; export * from './stageInstance'; +export * from './sticker'; export * from './teams'; export * from './template'; export * from './user'; diff --git a/payloads/v9/permissions.ts b/payloads/v9/permissions.ts index 774b0590..a75c9c01 100644 --- a/payloads/v9/permissions.ts +++ b/payloads/v9/permissions.ts @@ -42,7 +42,7 @@ export const PermissionFlagsBits = { ManageNicknames: 1n << 27n, ManageRoles: 1n << 28n, ManageWebhooks: 1n << 29n, - ManageEmojis: 1n << 30n, + ManageEmojisAndStickers: 1n << 30n, UseSlashCommands: 1n << 31n, RequestToSpeak: 1n << 32n, ManageThreads: 1n << 34n, diff --git a/payloads/v9/sticker.ts b/payloads/v9/sticker.ts new file mode 100644 index 00000000..1582dbf0 --- /dev/null +++ b/payloads/v9/sticker.ts @@ -0,0 +1,127 @@ +/** + * Types extracted from https://discord.com/developers/docs/resources/sticker + */ + +import type { Snowflake } from '../../globals'; +import type { APIUser } from './user'; + +/** + * https://discord.com/developers/docs/resources/sticker#sticker-object + */ +export interface APISticker { + /** + * ID of the sticker + */ + id: Snowflake; + /** + * For standard stickers, ID of the pack the sticker is from + */ + pack_id?: Snowflake; + /** + * Name of the sticker + */ + name: string; + /** + * Description of the sticker + */ + description: string | null; + /** + * For guild stickers, the Discord name of a unicode emoji representing the sticker's expression. for standard stickers, a comma-separated list of related expressions. + */ + tags: string; + /** + * Previously the sticker asset hash, now an empty string + * @deprecated + */ + asset: ''; + /** + * Type of sticker + * + * See https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-types + */ + type: StickerType; + /** + * Type of sticker format + * + * See https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-format-types + */ + format_type: StickerFormatType; + /** + * Whether this guild sticker can be used, may be false due to loss of Server Boosts + */ + available?: boolean; + /** + * ID of the guild that owns this sticker + */ + guild_id?: Snowflake; + /** + * The user that uploaded the guild sticker + */ + user?: APIUser; + /** + * The standard sticker's sort order within its pack + */ + sort_value?: number; +} + +/** + * https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-types + */ +export const enum StickerType { + /** + * An official sticker in a pack, part of Nitro or in a removed purchasable pack + */ + Standard = 1, + /** + * A sticker uploaded to a Boosted guild for the guild's members + */ + Guild, +} + +/** + * https://discord.com/developers/docs/resources/sticker#sticker-object-sticker-format-types + */ +export const enum StickerFormatType { + PNG = 1, + APNG, + Lottie, +} + +/** + * https://discord.com/developers/docs/resources/sticker#sticker-item-object + */ +export type APIStickerItem = Pick; + +/** + * https://discord.com/developers/docs/resources/sticker#sticker-object + */ +export interface APIStickerPack { + /** + * ID of the sticker pack + */ + id: Snowflake; + /** + * The stickers in the pack + */ + stickers: APISticker[]; + /** + * Name of the sticker pack + */ + name: string; + /** + * ID of the pack's SKU + */ + sku_id: Snowflake; + /** + * ID of a sticker in the pack which is shown as the pack's icon + */ + cover_sticker_id?: Snowflake; + /** + * Description of the sticker pack + */ + description: string; + /** + * ID of the sticker pack's banner image + */ + banner_asset_id: Snowflake; +} diff --git a/rest/common.ts b/rest/common.ts index 90d0d11d..8d3f5dce 100644 --- a/rest/common.ts +++ b/rest/common.ts @@ -32,6 +32,8 @@ export const enum RESTJSONErrorCodes { UnknownGuildTemplate = 10057, + UnknownSticker = 10060, + UnknownInteraction = 10062, UnknownApplicationCommand, @@ -61,6 +63,8 @@ export const enum RESTJSONErrorCodes { MaximumThreadParticipants = 30033, + MaximumNumberOfStickersReached = 30039, + Unauthorized = 40001, VerifyYourAccount, @@ -103,6 +107,9 @@ export const enum RESTJSONErrorCodes { InvalidAPIVersion = 50041, + FileUploadedExceedsMaximumSize = 50045, + InvalidFileUploaded, + CannotDeleteChannelRequiredForCommunityGuilds = 50074, InvalidStickerSent = 50081, @@ -120,5 +127,9 @@ export const enum RESTJSONErrorCodes { ThreadAlreadyCreatedForMessage = 160004, ThreadLocked, MaximumActiveThreads, - MaximumActiveAnnoucementThreads, + MaximumActiveAnnouncementThreads, + + InvalidJSONForUploadedLottieFile = 170001, + + LottieAnimationMaximumDimensionsExceeded = 170005, } diff --git a/rest/v8/channel.ts b/rest/v8/channel.ts index b454b92e..66004527 100644 --- a/rest/v8/channel.ts +++ b/rest/v8/channel.ts @@ -200,6 +200,12 @@ export interface RESTPostAPIChannelMessageJSONBody { * See https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure */ message_reference?: APIMessageReferenceSend; + /** + * IDs of up to 3 stickers in the server to send in the message + * + * See https://discord.com/developers/docs/resources/sticker#sticker-object + */ + sticker_ids?: [Snowflake] | [Snowflake, Snowflake] | [Snowflake, Snowflake, Snowflake]; } /** diff --git a/rest/v8/index.ts b/rest/v8/index.ts index c8b18aeb..bd432cb5 100644 --- a/rest/v8/index.ts +++ b/rest/v8/index.ts @@ -11,6 +11,7 @@ export * from './interactions'; export * from './invite'; export * from './oauth2'; export * from './stageInstance'; +export * from './sticker'; export * from './template'; export * from './user'; export * from './voice'; @@ -678,6 +679,41 @@ export const Routes = { stageInstance(channelID: Snowflake) { return `/stage-instances/${channelID}` as const; }, + + /** + * Route for: + * - GET `/stickers/{sticker.id}` + */ + sticker(stickerID: Snowflake) { + return `/stickers/${stickerID}` as const; + }, + + /** + * Route for: + * - GET `/sticker-packs` + */ + nitroStickerPacks() { + return '/sticker-packs' as const; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/stickers` + * - POST `/guilds/{guild.id}/stickers` + */ + guildStickers(guildID: Snowflake) { + return `/guilds/${guildID}/stickers` as const; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/stickers/{sticker.id}` + * - PATCH `/guilds/{guild.id}/stickers/{sticker.id}` + * - DELETE `/guilds/{guild.id}/stickers/{sticker.id}` + */ + guildSticker(guildID: Snowflake, stickerID: Snowflake) { + return `/guilds/${guildID}/stickers/${stickerID}` as const; + }, }; export const RouteBases = { diff --git a/rest/v8/sticker.ts b/rest/v8/sticker.ts new file mode 100644 index 00000000..ee7beba7 --- /dev/null +++ b/rest/v8/sticker.ts @@ -0,0 +1,51 @@ +import type { APISticker, APIStickerPack } from '../../payloads/v8/index'; + +export type RESTGetAPIStickerResult = APISticker; + +export interface RESTGetNitroStickerPacksResult { + sticker_packs: APIStickerPack[]; +} + +export type RESTGetAPIGuildStickersResult = APISticker[]; + +export type RESTGetAPIGuildStickerResult = APISticker; + +export interface RESTPostAPIGuildStickerFormDataBody { + /** + * Name of the sticker (2-30 characters) + */ + name: string; + /** + * Description of the sticker (empty or 2-100 characters) + */ + description: string; + /** + * The Discord name of a unicode emoji representing the sticker's expression (2-200 characters) + */ + tags: string; + /** + * The sticker file to upload, must be a PNG, APNG, or Lottie JSON file, max 500 KB + */ + file: unknown; +} + +export type RESTPostAPIGuildStickerResult = APISticker; + +export interface RESTPatchAPIGuildStickerJSONBody { + /** + * Name of the sticker (2-30 characters) + */ + name?: string; + /** + * Description of the sticker (2-100 characters) + */ + description?: string | null; + /** + * The Discord name of a unicode emoji representing the sticker's expression (2-200 characters) + */ + tags?: string; +} + +export type RESTPatchAPIGuildStickerResult = APISticker; + +export type RESTDeleteAPIGuildStickerResult = never; diff --git a/rest/v9/channel.ts b/rest/v9/channel.ts index ce1ccb13..75eb91db 100644 --- a/rest/v9/channel.ts +++ b/rest/v9/channel.ts @@ -228,6 +228,12 @@ export interface RESTPostAPIChannelMessageJSONBody { * See https://discord.com/developers/docs/resources/channel#message-object-message-reference-structure */ message_reference?: APIMessageReferenceSend; + /** + * IDs of up to 3 stickers in the server to send in the message + * + * See https://discord.com/developers/docs/resources/sticker#sticker-object + */ + sticker_ids?: [Snowflake] | [Snowflake, Snowflake] | [Snowflake, Snowflake, Snowflake]; } /** diff --git a/rest/v9/index.ts b/rest/v9/index.ts index 7d9578b2..b0afad3f 100644 --- a/rest/v9/index.ts +++ b/rest/v9/index.ts @@ -11,6 +11,7 @@ export * from './interactions'; export * from './invite'; export * from './oauth2'; export * from './stageInstance'; +export * from './sticker'; export * from './template'; export * from './user'; export * from './voice'; @@ -736,6 +737,41 @@ export const Routes = { stageInstance(channelID: Snowflake) { return `/stage-instances/${channelID}` as const; }, + + /** + * Route for: + * - GET `/stickers/{sticker.id}` + */ + sticker(stickerID: Snowflake) { + return `/stickers/${stickerID}` as const; + }, + + /** + * Route for: + * - GET `/sticker-packs` + */ + nitroStickerPacks() { + return '/sticker-packs' as const; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/stickers` + * - POST `/guilds/{guild.id}/stickers` + */ + guildStickers(guildID: Snowflake) { + return `/guilds/${guildID}/stickers` as const; + }, + + /** + * Route for: + * - GET `/guilds/{guild.id}/stickers/{sticker.id}` + * - PATCH `/guilds/{guild.id}/stickers/{sticker.id}` + * - DELETE `/guilds/{guild.id}/stickers/{sticker.id}` + */ + guildSticker(guildID: Snowflake, stickerID: Snowflake) { + return `/guilds/${guildID}/stickers/${stickerID}` as const; + }, }; export const RouteBases = { diff --git a/rest/v9/sticker.ts b/rest/v9/sticker.ts new file mode 100644 index 00000000..bab55e52 --- /dev/null +++ b/rest/v9/sticker.ts @@ -0,0 +1,51 @@ +import type { APISticker, APIStickerPack } from '../../payloads/v9/index'; + +export type RESTGetAPIStickerResult = APISticker; + +export interface RESTGetNitroStickerPacksResult { + sticker_packs: APIStickerPack[]; +} + +export type RESTGetAPIGuildStickersResult = APISticker[]; + +export type RESTGetAPIGuildStickerResult = APISticker; + +export interface RESTPostAPIGuildStickerFormDataBody { + /** + * Name of the sticker (2-30 characters) + */ + name: string; + /** + * Description of the sticker (empty or 2-100 characters) + */ + description: string; + /** + * The Discord name of a unicode emoji representing the sticker's expression (2-200 characters) + */ + tags: string; + /** + * The sticker file to upload, must be a PNG, APNG, or Lottie JSON file, max 500 KB + */ + file: unknown; +} + +export type RESTPostAPIGuildStickerResult = APISticker; + +export interface RESTPatchAPIGuildStickerJSONBody { + /** + * Name of the sticker (2-30 characters) + */ + name?: string; + /** + * Description of the sticker (2-100 characters) + */ + description?: string | null; + /** + * The Discord name of a unicode emoji representing the sticker's expression (2-200 characters) + */ + tags?: string; +} + +export type RESTPatchAPIGuildStickerResult = APISticker; + +export type RESTDeleteAPIGuildStickerResult = never;