From 377adec3aeb1e6aa7d7ecd183a46a869bb33c166 Mon Sep 17 00:00:00 2001 From: March 7th <71698422+aiko-chan-ai@users.noreply.github.com> Date: Thu, 26 Jan 2023 13:48:53 +0700 Subject: [PATCH] feat: Role subscriptions #9040 djs --- src/structures/Guild.js | 8 +++++++- src/structures/Integration.js | 1 + src/structures/Role.js | 8 ++++++++ src/util/Constants.js | 5 +++++ typings/enums.d.ts | 1 + typings/index.d.ts | 14 +++++++++++--- 6 files changed, 33 insertions(+), 4 deletions(-) diff --git a/src/structures/Guild.js b/src/structures/Guild.js index dc55b5e..644f9a1 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -226,9 +226,12 @@ class Guild extends AnonymousGuild { /** * An array of enabled guild features, here are the possible values: * * ANIMATED_ICON + * * AUTO_MODERATION * * BANNER * * COMMERCE * * COMMUNITY + * * CREATOR_MONETIZABLE_PROVISIONAL + * * CREATOR_STORE_PAGE * * DISCOVERABLE * * FEATURABLE * * INVITES_DISABLED @@ -243,12 +246,15 @@ class Guild extends AnonymousGuild { * * WELCOME_SCREEN_ENABLED * * TICKETED_EVENTS_ENABLED * * MONETIZATION_ENABLED + * `MONETIZATION_ENABLED` has been replaced. + * See [this pull request](https://github.com/discord/discord-api-docs/pull/5724) for more information. * * MORE_STICKERS * * THREE_DAY_THREAD_ARCHIVE * * SEVEN_DAY_THREAD_ARCHIVE * * PRIVATE_THREADS * * ROLE_ICONS - * * AUTO_MODERATION + * * ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE + * * ROLE_SUBSCRIPTIONS_ENABLED * @typedef {string} Features * @see {@link https://discord.com/developers/docs/resources/guild#guild-object-guild-features} */ diff --git a/src/structures/Integration.js b/src/structures/Integration.js index a2f9d7e..ec393d5 100644 --- a/src/structures/Integration.js +++ b/src/structures/Integration.js @@ -15,6 +15,7 @@ const IntegrationApplication = require('./IntegrationApplication'); * * `twitch` * * `youtube` * * `discord` + * * `guild_subscription` * @typedef {string} IntegrationType */ diff --git a/src/structures/Role.js b/src/structures/Role.js index fbacb74..cf59017 100644 --- a/src/structures/Role.js +++ b/src/structures/Role.js @@ -117,6 +117,8 @@ class Role extends Base { * @property {Snowflake} [botId] The id of the bot this role belongs to * @property {Snowflake|string} [integrationId] The id of the integration this role belongs to * @property {true} [premiumSubscriberRole] Whether this is the guild's premium subscription role + * @property {Snowflake} [subscriptionListingId] The id of this role's subscription SKU and listing + * @property {true} [availableForPurchase] Whether this role is available for purchase */ this.tags = data.tags ? {} : null; if (data.tags) { @@ -129,6 +131,12 @@ class Role extends Base { if ('premium_subscriber' in data.tags) { this.tags.premiumSubscriberRole = true; } + if ('subscription_listing_id' in data.tags) { + this.tags.subscriptionListingId = data.tags.subscription_listing_id; + } + if ('available_for_purchase' in data.tags) { + this.tags.availableForPurchase = true; + } } } diff --git a/src/util/Constants.js b/src/util/Constants.js index 373df35..896c8a1 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -733,6 +733,7 @@ exports.IntegrationExpireBehaviors = createEnum(['REMOVE_ROLE', 'KICK']); * * GUILD_INVITE_REMINDER * * CONTEXT_MENU_COMMAND * * AUTO_MODERATION_ACTION + * * ROLE_SUBSCRIPTION_PURCHASE * @typedef {string} MessageType * @see {@link https://discord.com/developers/docs/resources/channel#message-object-message-types} */ @@ -762,6 +763,7 @@ exports.MessageTypes = [ 'GUILD_INVITE_REMINDER', 'CONTEXT_MENU_COMMAND', 'AUTO_MODERATION_ACTION', + 'ROLE_SUBSCRIPTION_PURCHASE', ]; /** @@ -1256,6 +1258,7 @@ exports.APIErrors = { MAXIMUM_NUMBER_OF_STICKERS_REACHED: 30039, MAXIMUM_PRUNE_REQUESTS: 30040, MAXIMUM_GUILD_WIDGET_SETTINGS_UPDATE: 30042, + MAXIMUM_NUMBER_OF_PREMIUM_EMOJIS: 30056, UNAUTHORIZED: 40001, ACCOUNT_VERIFICATION_REQUIRED: 40002, DIRECT_MESSAGES_TOO_FAST: 40003, @@ -1325,6 +1328,8 @@ exports.APIErrors = { INVALID_ACTIVITY_LAUNCH_CONCURRENT_ACTIVITIES: 50108, INVALID_JSON: 50109, INVALID_FILE_ASSET_SIZE_RESIZE_GIF: 50138, + CANNOT_MIX_SUBSCRIPTION_AND_NON_SUBSCRIPTION_ROLES_FOR_EMOJI: 50144, + CANNOT_CONVERT_PREMIUM_EMOJI_TO_NORMAL_EMOJI: 50145, TWO_FACTOR_ENABLED: 60001, TWO_FACTOR_DISABLED: 60002, TWO_FACTOR_REQUIRED: 60003, diff --git a/typings/enums.d.ts b/typings/enums.d.ts index b94f2fc..f4077cb 100644 --- a/typings/enums.d.ts +++ b/typings/enums.d.ts @@ -172,6 +172,7 @@ export const enum MessageTypes { GUILD_INVITE_REMINDER, CONTEXT_MENU_COMMAND, AUTO_MODERATION_ACTION, + ROLE_SUBSCRIPTION_PURCHASE, } export const enum DefaultMessageNotificationLevels { diff --git a/typings/index.d.ts b/typings/index.d.ts index d4635a0..51be339 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -4435,6 +4435,7 @@ export interface APIErrors { MAXIMUM_NUMBER_OF_STICKERS_REACHED: 30039; MAXIMUM_PRUNE_REQUESTS: 30040; MAXIMUM_GUILD_WIDGET_SETTINGS_UPDATE: 30042; + MAXIMUM_NUMBER_OF_PREMIUM_EMOJIS: 30056; UNAUTHORIZED: 40001; ACCOUNT_VERIFICATION_REQUIRED: 40002; DIRECT_MESSAGES_TOO_FAST: 40003; @@ -4489,6 +4490,8 @@ export interface APIErrors { GUILD_MONETIZATION_REQUIRED: 50097; INSUFFICIENT_BOOSTS: 50101; INVALID_JSON: 50109; + CANNOT_MIX_SUBSCRIPTION_AND_NON_SUBSCRIPTION_ROLES_FOR_EMOJI: 50144; + CANNOT_CONVERT_PREMIUM_EMOJI_TO_NORMAL_EMOJI: 50145; TWO_FACTOR_REQUIRED: 60003; INVALID_TWO_FACTOR_CODE: 60008; NO_USERS_WITH_DISCORDTAG_EXIST: 80004; @@ -6088,9 +6091,12 @@ export interface GuildStickerEditData { export type GuildFeatures = | 'ANIMATED_ICON' + | 'AUTO_MODERATION' | 'BANNER' | 'COMMERCE' | 'COMMUNITY' + | 'CREATOR_MONETIZABLE_PROVISIONAL' + | 'CREATOR_STORE_PAGE' | 'DISCOVERABLE' | 'FEATURABLE' | 'INVITES_DISABLED' @@ -6104,13 +6110,13 @@ export type GuildFeatures = | 'VIP_REGIONS' | 'WELCOME_SCREEN_ENABLED' | 'TICKETED_EVENTS_ENABLED' - | 'MONETIZATION_ENABLED' | 'MORE_STICKERS' | 'THREE_DAY_THREAD_ARCHIVE' | 'SEVEN_DAY_THREAD_ARCHIVE' | 'PRIVATE_THREADS' | 'ROLE_ICONS' - | 'AUTO_MODERATION'; + | 'ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE' + | 'ROLE_SUBSCRIPTIONS_ENABLED'; export interface GuildMemberEditData { nick?: string | null; @@ -6248,7 +6254,7 @@ export interface ImageURLOptions extends Omit { format?: DynamicImageFormat; } -export type IntegrationType = 'twitch' | 'youtube' | 'discord'; +export type IntegrationType = 'twitch' | 'youtube' | 'discord' | 'guild_subscription'; export interface InteractionCollectorOptions extends CollectorOptions<[T]> { @@ -6899,6 +6905,8 @@ export interface RoleTagData { botId?: Snowflake; integrationId?: Snowflake; premiumSubscriberRole?: true; + subscriptionListingId?: Snowflake; + availableForPurchase?: true; } export interface SetChannelPositionOptions {