Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add role subscriptions #8915

Merged
merged 3 commits into from
Jan 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/discord.js/src/structures/Integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const IntegrationApplication = require('./IntegrationApplication');
* * `twitch`
* * `youtube`
* * `discord`
* * `guild_subscription`
* @typedef {string} IntegrationType
*/

Expand Down
8 changes: 8 additions & 0 deletions packages/discord.js/src/structures/Role.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
almeidx marked this conversation as resolved.
Show resolved Hide resolved
* @property {true} [availableForPurchase] Whether this role is available for purchase
*/
this.tags = data.tags ? {} : null;
if (data.tags) {
Expand All @@ -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;
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5514,7 +5514,7 @@ export interface IntegrationAccount {
name: string;
}

export type IntegrationType = 'twitch' | 'youtube' | 'discord';
export type IntegrationType = 'twitch' | 'youtube' | 'discord' | 'guild_subscription';

export type CollectedInteraction<Cached extends CacheType = CacheType> =
| StringSelectMenuInteraction<Cached>
Expand Down Expand Up @@ -5965,6 +5965,8 @@ export interface RoleTagData {
botId?: Snowflake;
integrationId?: Snowflake;
premiumSubscriberRole?: true;
subscriptionListingId?: Snowflake;
availableForPurchase?: true;
}

export interface SetChannelPositionOptions {
Expand Down