fix: temporary invite & feat: InviteFlags
This commit is contained in:
parent
289f812ec6
commit
6307a4b7f2
@ -553,6 +553,11 @@ class Client extends BaseClient {
|
|||||||
this.emit(Events.DEBUG, `[Invite > Guild ${i.guild?.id}] Joined`);
|
this.emit(Events.DEBUG, `[Invite > Guild ${i.guild?.id}] Joined`);
|
||||||
// Guild
|
// Guild
|
||||||
if (i.guild?.id) {
|
if (i.guild?.id) {
|
||||||
|
const guild = this.guilds.cache.get(i.guild?.id);
|
||||||
|
if (i.flags.has('GUEST')) {
|
||||||
|
this.emit(Events.DEBUG, `[Invite > Guild ${i.guild?.id}] Guest invite`);
|
||||||
|
return guild;
|
||||||
|
}
|
||||||
if (options.bypassOnboarding) {
|
if (options.bypassOnboarding) {
|
||||||
const onboardingData = await this.api.guilds[i.guild?.id].onboarding.get();
|
const onboardingData = await this.api.guilds[i.guild?.id].onboarding.get();
|
||||||
// Onboarding
|
// Onboarding
|
||||||
@ -607,7 +612,7 @@ class Client extends BaseClient {
|
|||||||
this.emit(Events.DEBUG, `[Invite > Guild ${i.guild?.id}] Bypassed verify`);
|
this.emit(Events.DEBUG, `[Invite > Guild ${i.guild?.id}] Bypassed verify`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.guilds.cache.get(i.guild?.id);
|
return guild;
|
||||||
} else {
|
} else {
|
||||||
return this.channels.cache.has(i.channelId);
|
return this.channels.cache.has(i.channelId);
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,7 @@ module.exports = (client, { d: data }, shard) => {
|
|||||||
const guild = client.guilds.cache.get(gSetting.guild_id);
|
const guild = client.guilds.cache.get(gSetting.guild_id);
|
||||||
if (guild) guild.settings._patch(gSetting);
|
if (guild) guild.settings._patch(gSetting);
|
||||||
}
|
}
|
||||||
|
// Todo: data.auth_session_id_hash
|
||||||
|
|
||||||
if (largeGuilds.length) {
|
if (largeGuilds.length) {
|
||||||
client.ws.broadcast({
|
client.ws.broadcast({
|
||||||
|
@ -47,17 +47,21 @@ class ClientUser extends User {
|
|||||||
if ('purchased_flags' in data) {
|
if ('purchased_flags' in data) {
|
||||||
/**
|
/**
|
||||||
* Purchased state of the client user.
|
* 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) {
|
if ('premium_usage_flags' in data) {
|
||||||
/**
|
/**
|
||||||
* Premium usage state of the client user.
|
* Premium usage state of the client user.
|
||||||
* @type {?PremiumUsageFlags}
|
* @type {Readonly<PremiumUsageFlags>}
|
||||||
*/
|
*/
|
||||||
this.premiumUsageFlags = new PremiumUsageFlags(data.premium_usage_flags || 0);
|
this.premiumUsageFlags = new PremiumUsageFlags(data.premium_usage_flags || 0);
|
||||||
|
} else {
|
||||||
|
this.premiumUsageFlags = new PremiumUsageFlags().freeze();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('phone' in data) {
|
if ('phone' in data) {
|
||||||
|
@ -6,6 +6,7 @@ const IntegrationApplication = require('./IntegrationApplication');
|
|||||||
const InviteStageInstance = require('./InviteStageInstance');
|
const InviteStageInstance = require('./InviteStageInstance');
|
||||||
const { Error } = require('../errors');
|
const { Error } = require('../errors');
|
||||||
const { Endpoints } = require('../util/Constants');
|
const { Endpoints } = require('../util/Constants');
|
||||||
|
const InviteFlags = require('../util/InviteFlags');
|
||||||
const Permissions = require('../util/Permissions');
|
const Permissions = require('../util/Permissions');
|
||||||
|
|
||||||
// TODO: Convert `inviter` and `channel` in this class to a getter.
|
// TODO: Convert `inviter` and `channel` in this class to a getter.
|
||||||
@ -242,6 +243,16 @@ class Invite extends Base {
|
|||||||
} else {
|
} else {
|
||||||
this.guildScheduledEvent ??= null;
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
29
src/util/InviteFlags.js
Normal file
29
src/util/InviteFlags.js
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const BitField = require('./BitField');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data structure that makes it easy to interact with an {@link InviteFlags#flags} bitfield.
|
||||||
|
* @extends {BitField}
|
||||||
|
*/
|
||||||
|
class InviteFlags extends BitField {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name InviteFlags
|
||||||
|
* @kind constructor
|
||||||
|
* @memberof InviteFlags
|
||||||
|
* @param {BitFieldResolvable} [bits=0] Bit(s) to read from
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Numeric the Discord invite flags. All available properties:
|
||||||
|
* * `GUEST`
|
||||||
|
* * `VIEWED`
|
||||||
|
* @type {Object}
|
||||||
|
*/
|
||||||
|
InviteFlags.FLAGS = {
|
||||||
|
GUEST: 1 << 0,
|
||||||
|
VIEWED: 1 << 1,
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = InviteFlags;
|
12
typings/index.d.ts
vendored
12
typings/index.d.ts
vendored
@ -334,6 +334,11 @@ export class PremiumUsageFlags extends BitField<PremiumUsageFlagsString> {
|
|||||||
public static resolve(bit?: BitFieldResolvable<PremiumUsageFlagsString, number>): number;
|
public static resolve(bit?: BitFieldResolvable<PremiumUsageFlagsString, number>): number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class InviteFlags extends BitField<InviteFlagsString> {
|
||||||
|
public static FLAGS: Record<InviteFlagsString, number>;
|
||||||
|
public static resolve(bit?: BitFieldResolvable<InviteFlagsString, 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;
|
||||||
@ -873,8 +878,8 @@ export class ClientUser extends User {
|
|||||||
public setPresence(data: PresenceData): ClientPresence;
|
public setPresence(data: PresenceData): ClientPresence;
|
||||||
public setStatus(status: PresenceStatusData, shardId?: number | number[]): ClientPresence;
|
public setStatus(status: PresenceStatusData, shardId?: number | number[]): ClientPresence;
|
||||||
public setUsername(username: string, password: string): Promise<this>;
|
public setUsername(username: string, password: string): Promise<this>;
|
||||||
public purchasedFlags: PurchasedFlags;
|
public purchasedFlags: Readonly<PurchasedFlags>;
|
||||||
public premiumUsageFlags: PremiumUsageFlags;
|
public premiumUsageFlags: Readonly<PremiumUsageFlags>;
|
||||||
public phone: string | null;
|
public phone: string | null;
|
||||||
public nsfwAllowed?: boolean;
|
public nsfwAllowed?: boolean;
|
||||||
public email: string | null;
|
public email: string | null;
|
||||||
@ -1751,6 +1756,7 @@ export class Invite extends Base {
|
|||||||
public static INVITES_PATTERN: RegExp;
|
public static INVITES_PATTERN: RegExp;
|
||||||
public stageInstance: InviteStageInstance | null;
|
public stageInstance: InviteStageInstance | null;
|
||||||
public guildScheduledEvent: GuildScheduledEvent | null;
|
public guildScheduledEvent: GuildScheduledEvent | null;
|
||||||
|
public flags: Readonly<InviteFlags>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class InviteStageInstance extends Base {
|
export class InviteStageInstance extends Base {
|
||||||
@ -4365,6 +4371,8 @@ export type PurchasedFlagsString = 'NITRO_CLASSIC' | 'NITRO' | 'GUILD_BOOST' | '
|
|||||||
|
|
||||||
export type PremiumUsageFlagsString = 'PREMIUM_DISCRIMINATOR' | 'ANIMATED_AVATAR' | 'PROFILE_BANNER';
|
export type PremiumUsageFlagsString = 'PREMIUM_DISCRIMINATOR' | 'ANIMATED_AVATAR' | 'PROFILE_BANNER';
|
||||||
|
|
||||||
|
export type InviteFlagsString = 'GUEST' | 'VIEWED';
|
||||||
|
|
||||||
export type ActivitiesOptions = Omit<ActivityOptions, 'shardId'>;
|
export type ActivitiesOptions = Omit<ActivityOptions, 'shardId'>;
|
||||||
|
|
||||||
export interface ActivityOptions {
|
export interface ActivityOptions {
|
||||||
|
Loading…
Reference in New Issue
Block a user