mirror of
https://github.com/discordeno/discordeno.git
synced 2026-09-17 08:47:22 +00:00
feat(bot,client,types): add role subscriptions (#2899)
Closes: https://github.com/discordeno/discordeno/issues/2859 Co-authored-by: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com>
This commit is contained in:
@@ -53,6 +53,10 @@ export const GuildToggle = {
|
||||
partnered: 1n << 9n,
|
||||
/** Whether the guild can enable welcome screen, Membership Screening, stage channels and discovery, and receives community updates */
|
||||
community: 1n << 10n,
|
||||
/** Whether the guild has enabled monetization. */
|
||||
creatorMonetizableProvisional: 1n << 31n,
|
||||
/** Whether the guild has enabled the role subscription promo page. */
|
||||
creatorStorePage: 1n << 32n,
|
||||
/** Whether the guild has access to set an animated guild banner image */
|
||||
animatedBanner: 1n << 11n,
|
||||
/** Whether the guild has access to create news channels */
|
||||
@@ -81,6 +85,10 @@ export const GuildToggle = {
|
||||
privateThreads: 1n << 26n,
|
||||
/** Whether the guild is able to set role icons */
|
||||
roleIcons: 1n << 27n,
|
||||
/** Whether the guild has role subscriptions that can be purchased. */
|
||||
roleSubscriptionsAvailableForPurchase: 1n << 33n,
|
||||
/** Whether the guild has enabled role subscriptions. */
|
||||
roleSubscriptionsEnabled: 1n << 34n,
|
||||
/** Whether the guild has set up auto moderation rules */
|
||||
autoModeration: 1n << 28n,
|
||||
/** Whether the guild has paused invites, preventing new users from joining */
|
||||
@@ -111,6 +119,8 @@ export class GuildToggles extends ToggleBitfieldBigint {
|
||||
if (guild.features.includes(GuildFeatures.Verified)) this.add(GuildToggle.verified)
|
||||
if (guild.features.includes(GuildFeatures.Partnered)) this.add(GuildToggle.partnered)
|
||||
if (guild.features.includes(GuildFeatures.Community)) this.add(GuildToggle.community)
|
||||
if (guild.features.includes(GuildFeatures.CreatorMonetizableProvisional)) this.add(GuildToggle.creatorMonetizableProvisional)
|
||||
if (guild.features.includes(GuildFeatures.CreatorStorePage)) this.add(GuildToggle.creatorStorePage)
|
||||
if (guild.features.includes(GuildFeatures.DeveloperSupportServer)) this.add(GuildToggle.developerSupportServer)
|
||||
if (guild.features.includes(GuildFeatures.AnimatedBanner)) this.add(GuildToggle.animatedBanner)
|
||||
if (guild.features.includes(GuildFeatures.News)) this.add(GuildToggle.news)
|
||||
@@ -124,10 +134,11 @@ export class GuildToggles extends ToggleBitfieldBigint {
|
||||
}
|
||||
if (guild.features.includes(GuildFeatures.PreviewEnabled)) this.add(GuildToggle.previewEnabled)
|
||||
if (guild.features.includes(GuildFeatures.TicketedEventsEnabled)) this.add(GuildToggle.ticketedEventsEnabled)
|
||||
if (guild.features.includes(GuildFeatures.MonetizationEnabled)) this.add(GuildToggle.monetizationEnabled)
|
||||
if (guild.features.includes(GuildFeatures.MoreStickers)) this.add(GuildToggle.moreStickers)
|
||||
if (guild.features.includes(GuildFeatures.PrivateThreads)) this.add(GuildToggle.privateThreads)
|
||||
if (guild.features.includes(GuildFeatures.RoleIcons)) this.add(GuildToggle.roleIcons)
|
||||
if (guild.features.includes(GuildFeatures.RoleSubscriptionsAvailableForPurchase)) this.add(GuildToggle.roleSubscriptionsAvailableForPurchase)
|
||||
if (guild.features.includes(GuildFeatures.RoleSubscriptionsEnabled)) this.add(GuildToggle.roleSubscriptionsEnabled)
|
||||
if (guild.features.includes(GuildFeatures.AutoModeration)) this.add(GuildToggle.autoModeration)
|
||||
if (guild.features.includes(GuildFeatures.InvitesDisabled)) this.add(GuildToggle.invitesDisabled)
|
||||
}
|
||||
|
||||
@@ -10,6 +10,10 @@ export const RoleToggle = {
|
||||
mentionable: 1 << 2,
|
||||
/** Whether this is the guilds premium subscriber role */
|
||||
premiumSubscriber: 1 << 3,
|
||||
/** Whether this role is available for purchase. */
|
||||
availableForPurchase: 1 << 4,
|
||||
/** Whether this role is available for guild connections. */
|
||||
guildConnections: 1 << 5,
|
||||
}
|
||||
|
||||
export class RoleToggles extends ToggleBitfield {
|
||||
@@ -24,6 +28,8 @@ export class RoleToggles extends ToggleBitfield {
|
||||
if (role.managed) this.add(RoleToggle.managed)
|
||||
if (role.mentionable) this.add(RoleToggle.mentionable)
|
||||
if (role.tags?.premium_subscriber === null) this.add(RoleToggle.premiumSubscriber)
|
||||
if (role.tags?.available_for_purchase === null) this.add(RoleToggle.availableForPurchase)
|
||||
if (role.tags?.guild_connections === null) this.add(RoleToggle.guildConnections)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -180,17 +180,19 @@ export const GuildFeatures = [
|
||||
'BANNER',
|
||||
'COMMERCE',
|
||||
'COMMUNITY',
|
||||
'CREATOR_MONETIZABLE_PROVISIONAL',
|
||||
'CREATOR_STORE_PAGE',
|
||||
'DISCOVERABLE',
|
||||
'FEATURABLE',
|
||||
'INVITE_SPLASH',
|
||||
'MEMBER_VERIFICATION_GATE_ENABLED',
|
||||
'MONETIZATION_ENABLED',
|
||||
'MORE_STICKERS',
|
||||
'NEWS',
|
||||
'PARTNERED',
|
||||
'PREVIEW_ENABLED',
|
||||
'PRIVATE_THREADS',
|
||||
'ROLE_ICONS',
|
||||
'ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE',
|
||||
'ROLE_SUBSCRIPTIONS_ENABLED',
|
||||
'SEVEN_DAY_THREAD_ARCHIVE',
|
||||
'THREE_DAY_THREAD_ARCHIVE',
|
||||
@@ -645,4 +647,4 @@ export const Constants = {
|
||||
WebhookTypes,
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
||||
export type Constants = typeof Constants;
|
||||
export type Constants = typeof Constants
|
||||
|
||||
@@ -20,7 +20,11 @@ export class Role extends Base {
|
||||
unicodeEmoji?: string
|
||||
position: number
|
||||
guild: Guild
|
||||
tags?: Omit<DiscordRoleTags, 'premium_subscriber'> & { premium_subscriber?: boolean }
|
||||
tags?: Omit<DiscordRoleTags, 'premium_subscriber' | 'available_for_purchase' | 'guild_connections'> & {
|
||||
premium_subscriber?: boolean
|
||||
available_for_purchase?: boolean
|
||||
guild_connections?: boolean
|
||||
}
|
||||
|
||||
constructor(data: DiscordRole, guild: Guild) {
|
||||
super(data.id)
|
||||
@@ -40,6 +44,9 @@ export class Role extends Base {
|
||||
bot_id: data.tags.bot_id,
|
||||
integration_id: data.tags.integration_id,
|
||||
premium_subscriber: data.tags.premium_subscriber === null,
|
||||
subscription_listing_id: data.tags.subscription_listing_id,
|
||||
available_for_purchase: data.tags.available_for_purchase === null,
|
||||
guild_connections: data.tags.guild_connections === null,
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
@@ -70,6 +77,8 @@ export class Role extends Base {
|
||||
this.tags = {
|
||||
bot_id: data.tags.bot_id,
|
||||
integration_id: data.tags.integration_id,
|
||||
subscription_listing_id: data.tags.subscription_listing_id,
|
||||
available_for_purchase: data.tags.available_for_purchase === null,
|
||||
premium_subscriber: data.tags.premium_subscriber === null,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ export interface DiscordIntegration {
|
||||
id: string
|
||||
/** Integration name */
|
||||
name: string
|
||||
/** Integration type (twitch, youtube or discord) */
|
||||
/** Integration type (twitch, youtube, discord, or guild_subscription). */
|
||||
type: 'twitch' | 'youtube' | 'discord'
|
||||
/** Is this integration enabled */
|
||||
enabled?: boolean
|
||||
@@ -616,6 +616,10 @@ export interface DiscordRoleTags {
|
||||
integration_id?: string
|
||||
/** Whether this is the guild's premium subscriber role */
|
||||
premium_subscriber?: null
|
||||
/** Id of this role's subscription sku and listing. */
|
||||
subscription_listing_id?: string
|
||||
/** Whether this role is available for purchase. */
|
||||
available_for_purchase?: null
|
||||
/** Whether this is a guild's linked role */
|
||||
guild_connections?: null
|
||||
}
|
||||
|
||||
@@ -187,6 +187,10 @@ export enum GuildFeatures {
|
||||
Partnered = 'PARTNERED',
|
||||
/** Guild can enable welcome screen, Membership Screening, stage channels and discovery, and receives community updates */
|
||||
Community = 'COMMUNITY',
|
||||
/** Guild has enabled monetization. */
|
||||
CreatorMonetizableProvisional = 'CREATOR_MONETIZABLE_PROVISIONAL',
|
||||
/** Guild has enabled the role subscription promo page. */
|
||||
CreatorStorePage = 'CREATOR_STORE_PAGE',
|
||||
/** Guild has been set as a support server on the App Directory */
|
||||
DeveloperSupportServer = 'DEVELOPER_SUPPORT_SERVER',
|
||||
/** Guild has access to create news channels */
|
||||
@@ -207,14 +211,16 @@ export enum GuildFeatures {
|
||||
PreviewEnabled = 'PREVIEW_ENABLED',
|
||||
/** Guild has enabled ticketed events */
|
||||
TicketedEventsEnabled = 'TICKETED_EVENTS_ENABLED',
|
||||
/** Guild has enabled monetization */
|
||||
MonetizationEnabled = 'MONETIZATION_ENABLED',
|
||||
/** Guild has increased custom sticker slots */
|
||||
MoreStickers = 'MORE_STICKERS',
|
||||
/** Guild has access to create private threads */
|
||||
PrivateThreads = 'PRIVATE_THREADS',
|
||||
/** Guild is able to set role icons */
|
||||
RoleIcons = 'ROLE_ICONS',
|
||||
/** Guild has role subscriptions that can be purchased. */
|
||||
RoleSubscriptionsAvailableForPurchase = 'ROLE_SUBSCRIPTIONS_AVAILABLE_FOR_PURCHASE',
|
||||
/** Guild has enabled role subscriptions. */
|
||||
RoleSubscriptionsEnabled = 'ROLE_SUBSCRIPTIONS_ENABLED',
|
||||
/** Guild has set up auto moderation rules */
|
||||
AutoModeration = 'AUTO_MODERATION',
|
||||
/** Guild has paused invites, preventing new users from joining */
|
||||
|
||||
Reference in New Issue
Block a user