feat: premiumUsageFlags

This commit is contained in:
March 7th 2022-12-22 19:37:05 +07:00
parent a6099af525
commit d75d457486
4 changed files with 47 additions and 2 deletions

View File

@ -109,8 +109,6 @@ module.exports = async (client, { d: data }, shard) => {
client.users.cache.set(client.user.id, client.user); client.users.cache.set(client.user.id, client.user);
} }
client.user.setAFK(false);
client.settings._patch(data.user_settings); client.settings._patch(data.user_settings);
client.user.connectedAccounts = data.connected_accounts ?? []; client.user.connectedAccounts = data.connected_accounts ?? [];

View File

@ -8,6 +8,7 @@ const { Util } = require('..');
const { Error: Error_ } = require('../errors'); const { Error: Error_ } = require('../errors');
const { Opcodes, NitroType, HypeSquadType } = require('../util/Constants'); const { Opcodes, NitroType, HypeSquadType } = require('../util/Constants');
const DataResolver = require('../util/DataResolver'); const DataResolver = require('../util/DataResolver');
const PremiumUsageFlags = require('../util/PremiumUsageFlags');
const PurchasedFlags = require('../util/PurchasedFlags'); const PurchasedFlags = require('../util/PurchasedFlags');
/** /**
* Represents the logged in client's Discord user. * Represents the logged in client's Discord user.
@ -53,6 +54,13 @@ class ClientUser extends User {
*/ */
this.purchasedFlags = new PurchasedFlags(data.purchased_flags || 0); this.purchasedFlags = new PurchasedFlags(data.purchased_flags || 0);
} }
if ('premium_usage_flags' in data) {
/**
* Premium usage state of the client user.
* @type {?PremiumUsageFlags}
*/
this.premiumUsageFlags = new PremiumUsageFlags(data.premium_usage_flags || 0);
}
// Key: premium = boolean; // Key: premium = boolean;
if ('phone' in data) { if ('phone' in data) {
/** /**

View File

@ -0,0 +1,30 @@
'use strict';
const BitField = require('./BitField');
/**
* Data structure that makes it easy to interact with an {@link PremiumUsageFlags#flags} bitfield.
* @extends {BitField}
*/
class PremiumUsageFlags extends BitField {}
/**
* @name PremiumUsageFlags
* @kind constructor
* @memberof PremiumUsageFlags
* @param {BitFieldResolvable} [bits=0] Bit(s) to read from
*/
/**
* Numeric the Discord premium usage flags. All available properties:
* * `ANIMATED_AVATAR`
* * `BANNER`
* * `CUSTOM_DISCRIMINATOR`
* @type {Object}
*/
PremiumUsageFlags.FLAGS = {
ANIMATED_AVATAR: 1 << 1,
BANNER: 1 << 2,
};
module.exports = PremiumUsageFlags;

9
typings/index.d.ts vendored
View File

@ -360,6 +360,11 @@ export class PurchasedFlags extends BitField<PurchasedFlagsString> {
public static resolve(bit?: BitFieldResolvable<PurchasedFlagsString, number>): number; public static resolve(bit?: BitFieldResolvable<PurchasedFlagsString, number>): number;
} }
export class PremiumUsageFlags extends BitField<PremiumUsageFlagsString> {
public static FLAGS: Record<PremiumUsageFlagsString, number>;
public static resolve(bit?: BitFieldResolvable<PremiumUsageFlagsString, number>): number;
}
export abstract class AnonymousGuild extends BaseGuild { export abstract class AnonymousGuild extends BaseGuild {
protected constructor(client: Client, data: RawAnonymousGuildData, immediatePatch?: boolean); protected constructor(client: Client, data: RawAnonymousGuildData, immediatePatch?: boolean);
public banner: string | null; public banner: string | null;
@ -951,6 +956,8 @@ export class ClientUser extends User {
public verified: boolean; public verified: boolean;
public notes: Collection<Snowflake, string>; public notes: Collection<Snowflake, string>;
public friendNicknames: Collection<Snowflake, string>; public friendNicknames: Collection<Snowflake, string>;
public purchasedFlags: PurchasedFlags;
public premiumUsageFlags: PremiumUsageFlags;
public setThemeColors(primary?: ColorResolvable, accent?: ColorResolvable): ClientUser; public setThemeColors(primary?: ColorResolvable, accent?: ColorResolvable): ClientUser;
public edit(data: ClientUserEditData): Promise<this>; public edit(data: ClientUserEditData): Promise<this>;
public setActivity(options?: ActivityOptions): ClientPresence; public setActivity(options?: ActivityOptions): ClientPresence;
@ -4240,6 +4247,8 @@ export interface WebhookFields extends PartialWebhookFields {
//#region Typedefs //#region Typedefs
export type PurchasedFlagsString = 'NITRO_CLASSIC' | 'NITRO' | 'GUILD_BOOST'; export type PurchasedFlagsString = 'NITRO_CLASSIC' | 'NITRO' | 'GUILD_BOOST';
export type PremiumUsageFlagsString = 'ANIMATED_AVATAR' | 'BANNER' | 'CUSTOM_DISCRIMINATOR';
export type ActivityFlagsString = export type ActivityFlagsString =
| 'INSTANCE' | 'INSTANCE'
| 'JOIN' | 'JOIN'