mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 10:33:30 +01:00
feat: Add role subscription data (#9025)
* feat: add role subscription data * docs: specify message type * types: use interface * docs: add word --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
@@ -198,6 +198,31 @@ class Message extends Base {
|
||||
this.position ??= null;
|
||||
}
|
||||
|
||||
if ('role_subscription_data' in data) {
|
||||
/**
|
||||
* Role subscription data found on {@link MessageType.RoleSubscriptionPurchase} messages.
|
||||
* @typedef {Object} RoleSubscriptionData
|
||||
* @property {Snowflake} roleSubscriptionListingId The id of the SKU and listing the user is subscribed to
|
||||
* @property {string} tierName The name of the tier the user is subscribed to
|
||||
* @property {number} totalMonthsSubscribed The total number of months the user has been subscribed for
|
||||
* @property {boolean} isRenewal Whether this notification is a renewal
|
||||
*/
|
||||
|
||||
/**
|
||||
* The data of the role subscription purchase or renewal.
|
||||
* <info>This is present on {@link MessageType.RoleSubscriptionPurchase} messages.</info>
|
||||
* @type {?RoleSubscriptionData}
|
||||
*/
|
||||
this.roleSubscriptionData = {
|
||||
roleSubscriptionListingId: data.role_subscription_data.role_subscription_listing_id,
|
||||
tierName: data.role_subscription_data.tier_name,
|
||||
totalMonthsSubscribed: data.role_subscription_data.total_months_subscribed,
|
||||
isRenewal: data.role_subscription_data.is_renewal,
|
||||
};
|
||||
} else {
|
||||
this.roleSubscriptionData ??= null;
|
||||
}
|
||||
|
||||
// Discord sends null if the message has not been edited
|
||||
if (data.edited_timestamp) {
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user