feat: role subscriptions (#9040)

* feat: add role subscriptions (#8915)

* feat: add role subscriptions

* docs: casing

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>

* chore: version 13 specific things

---------

Co-authored-by: Almeida <almeidx@pm.me>
This commit is contained in:
Jiralite
2023-02-17 22:12:47 +00:00
committed by GitHub
parent eed293f893
commit 0afa405f5a
6 changed files with 33 additions and 4 deletions

View File

@@ -228,9 +228,12 @@ class Guild extends AnonymousGuild {
/** /**
* An array of enabled guild features, here are the possible values: * An array of enabled guild features, here are the possible values:
* * ANIMATED_ICON * * ANIMATED_ICON
* * AUTO_MODERATION
* * BANNER * * BANNER
* * COMMERCE * * COMMERCE
* * COMMUNITY * * COMMUNITY
* * CREATOR_MONETIZABLE_PROVISIONAL
* * CREATOR_STORE_PAGE
* * DISCOVERABLE * * DISCOVERABLE
* * FEATURABLE * * FEATURABLE
* * INVITES_DISABLED * * INVITES_DISABLED
@@ -245,12 +248,15 @@ class Guild extends AnonymousGuild {
* * WELCOME_SCREEN_ENABLED * * WELCOME_SCREEN_ENABLED
* * TICKETED_EVENTS_ENABLED * * TICKETED_EVENTS_ENABLED
* * MONETIZATION_ENABLED * * MONETIZATION_ENABLED
* <warn>`MONETIZATION_ENABLED` has been replaced.
* See [this pull request](https://github.com/discord/discord-api-docs/pull/5724) for more information.</warn>
* * MORE_STICKERS * * MORE_STICKERS
* * THREE_DAY_THREAD_ARCHIVE * * THREE_DAY_THREAD_ARCHIVE
* * SEVEN_DAY_THREAD_ARCHIVE * * SEVEN_DAY_THREAD_ARCHIVE
* * PRIVATE_THREADS * * PRIVATE_THREADS
* * ROLE_ICONS * * ROLE_ICONS
* * AUTO_MODERATION * * ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE
* * ROLE_SUBSCRIPTIONS_ENABLED
* @typedef {string} Features * @typedef {string} Features
* @see {@link https://discord.com/developers/docs/resources/guild#guild-object-guild-features} * @see {@link https://discord.com/developers/docs/resources/guild#guild-object-guild-features}
*/ */

View File

@@ -15,6 +15,7 @@ const IntegrationApplication = require('./IntegrationApplication');
* * `twitch` * * `twitch`
* * `youtube` * * `youtube`
* * `discord` * * `discord`
* * `guild_subscription`
* @typedef {string} IntegrationType * @typedef {string} IntegrationType
*/ */

View File

@@ -117,6 +117,8 @@ class Role extends Base {
* @property {Snowflake} [botId] The id of the bot this role belongs to * @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 {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 {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; this.tags = data.tags ? {} : null;
if (data.tags) { if (data.tags) {
@@ -129,6 +131,12 @@ class Role extends Base {
if ('premium_subscriber' in data.tags) { if ('premium_subscriber' in data.tags) {
this.tags.premiumSubscriberRole = true; 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;
}
} }
} }

View File

@@ -555,6 +555,7 @@ exports.IntegrationExpireBehaviors = createEnum(['REMOVE_ROLE', 'KICK']);
* * GUILD_INVITE_REMINDER * * GUILD_INVITE_REMINDER
* * CONTEXT_MENU_COMMAND * * CONTEXT_MENU_COMMAND
* * AUTO_MODERATION_ACTION * * AUTO_MODERATION_ACTION
* * ROLE_SUBSCRIPTION_PURCHASE
* @typedef {string} MessageType * @typedef {string} MessageType
* @see {@link https://discord.com/developers/docs/resources/channel#message-object-message-types} * @see {@link https://discord.com/developers/docs/resources/channel#message-object-message-types}
*/ */
@@ -584,6 +585,7 @@ exports.MessageTypes = [
'GUILD_INVITE_REMINDER', 'GUILD_INVITE_REMINDER',
'CONTEXT_MENU_COMMAND', 'CONTEXT_MENU_COMMAND',
'AUTO_MODERATION_ACTION', 'AUTO_MODERATION_ACTION',
'ROLE_SUBSCRIPTION_PURCHASE',
]; ];
/** /**
@@ -1067,6 +1069,7 @@ exports.APIErrors = {
MAXIMUM_NUMBER_OF_STICKERS_REACHED: 30039, MAXIMUM_NUMBER_OF_STICKERS_REACHED: 30039,
MAXIMUM_PRUNE_REQUESTS: 30040, MAXIMUM_PRUNE_REQUESTS: 30040,
MAXIMUM_GUILD_WIDGET_SETTINGS_UPDATE: 30042, MAXIMUM_GUILD_WIDGET_SETTINGS_UPDATE: 30042,
MAXIMUM_NUMBER_OF_PREMIUM_EMOJIS: 30056,
UNAUTHORIZED: 40001, UNAUTHORIZED: 40001,
ACCOUNT_VERIFICATION_REQUIRED: 40002, ACCOUNT_VERIFICATION_REQUIRED: 40002,
DIRECT_MESSAGES_TOO_FAST: 40003, DIRECT_MESSAGES_TOO_FAST: 40003,
@@ -1119,6 +1122,8 @@ exports.APIErrors = {
GUILD_MONETIZATION_REQUIRED: 50097, GUILD_MONETIZATION_REQUIRED: 50097,
INSUFFICIENT_BOOSTS: 50101, INSUFFICIENT_BOOSTS: 50101,
INVALID_JSON: 50109, 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, TWO_FACTOR_REQUIRED: 60003,
NO_USERS_WITH_DISCORDTAG_EXIST: 80004, NO_USERS_WITH_DISCORDTAG_EXIST: 80004,
REACTION_BLOCKED: 90001, REACTION_BLOCKED: 90001,

1
typings/enums.d.ts vendored
View File

@@ -111,6 +111,7 @@ export const enum MessageTypes {
GUILD_INVITE_REMINDER, GUILD_INVITE_REMINDER,
CONTEXT_MENU_COMMAND, CONTEXT_MENU_COMMAND,
AUTO_MODERATION_ACTION, AUTO_MODERATION_ACTION,
ROLE_SUBSCRIPTION_PURCHASE,
} }
export const enum DefaultMessageNotificationLevels { export const enum DefaultMessageNotificationLevels {

14
typings/index.d.ts vendored
View File

@@ -3848,6 +3848,7 @@ export interface APIErrors {
MAXIMUM_NUMBER_OF_STICKERS_REACHED: 30039; MAXIMUM_NUMBER_OF_STICKERS_REACHED: 30039;
MAXIMUM_PRUNE_REQUESTS: 30040; MAXIMUM_PRUNE_REQUESTS: 30040;
MAXIMUM_GUILD_WIDGET_SETTINGS_UPDATE: 30042; MAXIMUM_GUILD_WIDGET_SETTINGS_UPDATE: 30042;
MAXIMUM_NUMBER_OF_PREMIUM_EMOJIS: 30056;
UNAUTHORIZED: 40001; UNAUTHORIZED: 40001;
ACCOUNT_VERIFICATION_REQUIRED: 40002; ACCOUNT_VERIFICATION_REQUIRED: 40002;
DIRECT_MESSAGES_TOO_FAST: 40003; DIRECT_MESSAGES_TOO_FAST: 40003;
@@ -3900,6 +3901,8 @@ export interface APIErrors {
GUILD_MONETIZATION_REQUIRED: 50097; GUILD_MONETIZATION_REQUIRED: 50097;
INSUFFICIENT_BOOSTS: 50101; INSUFFICIENT_BOOSTS: 50101;
INVALID_JSON: 50109; 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; TWO_FACTOR_REQUIRED: 60003;
NO_USERS_WITH_DISCORDTAG_EXIST: 80004; NO_USERS_WITH_DISCORDTAG_EXIST: 80004;
REACTION_BLOCKED: 90001; REACTION_BLOCKED: 90001;
@@ -5366,9 +5369,12 @@ export interface GuildStickerEditData {
export type GuildFeatures = export type GuildFeatures =
| 'ANIMATED_ICON' | 'ANIMATED_ICON'
| 'AUTO_MODERATION'
| 'BANNER' | 'BANNER'
| 'COMMERCE' | 'COMMERCE'
| 'COMMUNITY' | 'COMMUNITY'
| 'CREATOR_MONETIZABLE_PROVISIONAL'
| 'CREATOR_STORE_PAGE'
| 'DISCOVERABLE' | 'DISCOVERABLE'
| 'FEATURABLE' | 'FEATURABLE'
| 'INVITES_DISABLED' | 'INVITES_DISABLED'
@@ -5382,13 +5388,13 @@ export type GuildFeatures =
| 'VIP_REGIONS' | 'VIP_REGIONS'
| 'WELCOME_SCREEN_ENABLED' | 'WELCOME_SCREEN_ENABLED'
| 'TICKETED_EVENTS_ENABLED' | 'TICKETED_EVENTS_ENABLED'
| 'MONETIZATION_ENABLED'
| 'MORE_STICKERS' | 'MORE_STICKERS'
| 'THREE_DAY_THREAD_ARCHIVE' | 'THREE_DAY_THREAD_ARCHIVE'
| 'SEVEN_DAY_THREAD_ARCHIVE' | 'SEVEN_DAY_THREAD_ARCHIVE'
| 'PRIVATE_THREADS' | 'PRIVATE_THREADS'
| 'ROLE_ICONS' | 'ROLE_ICONS'
| 'AUTO_MODERATION'; | 'ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE'
| 'ROLE_SUBSCRIPTIONS_ENABLED';
export interface GuildMemberEditData { export interface GuildMemberEditData {
nick?: string | null; nick?: string | null;
@@ -5528,7 +5534,7 @@ export interface ImageURLOptions extends Omit<StaticImageURLOptions, 'format'> {
format?: DynamicImageFormat; format?: DynamicImageFormat;
} }
export type IntegrationType = 'twitch' | 'youtube' | 'discord'; export type IntegrationType = 'twitch' | 'youtube' | 'discord' | 'guild_subscription';
export interface InteractionCollectorOptions<T extends Interaction, Cached extends CacheType = CacheType> export interface InteractionCollectorOptions<T extends Interaction, Cached extends CacheType = CacheType>
extends CollectorOptions<[T]> { extends CollectorOptions<[T]> {
@@ -6147,6 +6153,8 @@ export interface RoleTagData {
botId?: Snowflake; botId?: Snowflake;
integrationId?: Snowflake; integrationId?: Snowflake;
premiumSubscriberRole?: true; premiumSubscriberRole?: true;
subscriptionListingId?: Snowflake;
availableForPurchase?: true;
} }
export interface SetChannelPositionOptions { export interface SetChannelPositionOptions {