fix: temporary invite & feat: InviteFlags
This commit is contained in:
@@ -553,6 +553,11 @@ class Client extends BaseClient {
|
||||
this.emit(Events.DEBUG, `[Invite > Guild ${i.guild?.id}] Joined`);
|
||||
// Guild
|
||||
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) {
|
||||
const onboardingData = await this.api.guilds[i.guild?.id].onboarding.get();
|
||||
// Onboarding
|
||||
@@ -607,7 +612,7 @@ class Client extends BaseClient {
|
||||
this.emit(Events.DEBUG, `[Invite > Guild ${i.guild?.id}] Bypassed verify`);
|
||||
}
|
||||
}
|
||||
return this.guilds.cache.get(i.guild?.id);
|
||||
return guild;
|
||||
} else {
|
||||
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);
|
||||
if (guild) guild.settings._patch(gSetting);
|
||||
}
|
||||
// Todo: data.auth_session_id_hash
|
||||
|
||||
if (largeGuilds.length) {
|
||||
client.ws.broadcast({
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
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;
|
||||
Reference in New Issue
Block a user