fix: temporary invite & feat: InviteFlags

This commit is contained in:
Elysia
2024-01-30 12:26:40 +07:00
parent 289f812ec6
commit 6307a4b7f2
6 changed files with 64 additions and 6 deletions

View File

@@ -47,17 +47,21 @@ class ClientUser extends User {
if ('purchased_flags' in data) {
/**
* Purchased state of the client user.
* @type {?PurchasedFlags}
* @type {Readonly<PurchasedFlags>}
*/
this.purchasedFlags = new PurchasedFlags(data.purchased_flags || 0);
this.purchasedFlags = new PurchasedFlags(data.purchased_flags || 0).freeze();
} else {
this.purchasedFlags = new PurchasedFlags().freeze();
}
if ('premium_usage_flags' in data) {
/**
* Premium usage state of the client user.
* @type {?PremiumUsageFlags}
* @type {Readonly<PremiumUsageFlags>}
*/
this.premiumUsageFlags = new PremiumUsageFlags(data.premium_usage_flags || 0);
} else {
this.premiumUsageFlags = new PremiumUsageFlags().freeze();
}
if ('phone' in data) {

View File

@@ -6,6 +6,7 @@ const IntegrationApplication = require('./IntegrationApplication');
const InviteStageInstance = require('./InviteStageInstance');
const { Error } = require('../errors');
const { Endpoints } = require('../util/Constants');
const InviteFlags = require('../util/InviteFlags');
const Permissions = require('../util/Permissions');
// TODO: Convert `inviter` and `channel` in this class to a getter.
@@ -242,6 +243,16 @@ class Invite extends Base {
} else {
this.guildScheduledEvent ??= null;
}
if ('flags' in data) {
/**
* The flags that are applied to the invite.
* @type {?Readonly<InviteFlags>}
*/
this.flags = new InviteFlags(data.flags).freeze();
} else {
this.flags ??= new InviteFlags().freeze();
}
}
/**