From 3407e1eea3c8d5629465553f342ac30ceae27a47 Mon Sep 17 00:00:00 2001 From: Almeida Date: Wed, 4 Jan 2023 00:39:31 +0000 Subject: [PATCH] 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> --- packages/discord.js/src/structures/Integration.js | 1 + packages/discord.js/src/structures/Role.js | 8 ++++++++ packages/discord.js/typings/index.d.ts | 4 +++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/discord.js/src/structures/Integration.js b/packages/discord.js/src/structures/Integration.js index d51dfbda8..fa9777b38 100644 --- a/packages/discord.js/src/structures/Integration.js +++ b/packages/discord.js/src/structures/Integration.js @@ -16,6 +16,7 @@ const IntegrationApplication = require('./IntegrationApplication'); * * `twitch` * * `youtube` * * `discord` + * * `guild_subscription` * @typedef {string} IntegrationType */ diff --git a/packages/discord.js/src/structures/Role.js b/packages/discord.js/src/structures/Role.js index 8c3487479..35526c1c4 100644 --- a/packages/discord.js/src/structures/Role.js +++ b/packages/discord.js/src/structures/Role.js @@ -107,6 +107,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) { @@ -119,6 +121,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/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 336d3cdd9..20c99a543 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -5585,7 +5585,7 @@ export interface IntegrationAccount { name: string; } -export type IntegrationType = 'twitch' | 'youtube' | 'discord'; +export type IntegrationType = 'twitch' | 'youtube' | 'discord' | 'guild_subscription'; export type CollectedInteraction = | StringSelectMenuInteraction @@ -6030,6 +6030,8 @@ export interface RoleTagData { botId?: Snowflake; integrationId?: Snowflake; premiumSubscriberRole?: true; + subscriptionListingId?: Snowflake; + availableForPurchase?: true; } export interface SetChannelPositionOptions {