feat: disable client.acceptInvite()
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable no-unreachable */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const process = require('node:process');
|
const process = require('node:process');
|
||||||
@@ -560,10 +561,18 @@ class Client extends BaseClient {
|
|||||||
* @param {InviteResolvable} invite Invite code or URL
|
* @param {InviteResolvable} invite Invite code or URL
|
||||||
* @param {AcceptInviteOptions} [options] Options
|
* @param {AcceptInviteOptions} [options] Options
|
||||||
* @returns {Promise<Guild|DMChannel|GroupDMChannel>}
|
* @returns {Promise<Guild|DMChannel|GroupDMChannel>}
|
||||||
|
* @deprecated I will temporarily disable this feature because it can cause the account to be locked (and I also don't have tokens to test anymore).
|
||||||
* @example
|
* @example
|
||||||
* await client.acceptInvite('https://discord.gg/genshinimpact', { bypassOnboarding: true, bypassVerify: true })
|
* await client.acceptInvite('https://discord.gg/genshinimpact', { bypassOnboarding: true, bypassVerify: true })
|
||||||
*/
|
*/
|
||||||
async acceptInvite(invite, options = { bypassOnboarding: true, bypassVerify: true }) {
|
async acceptInvite(invite, options = { bypassOnboarding: true, bypassVerify: true }) {
|
||||||
|
return new Promise((_, e) =>
|
||||||
|
// eslint-disable-next-line prefer-promise-reject-errors
|
||||||
|
e({
|
||||||
|
success: false,
|
||||||
|
msg: "I will temporarily disable this feature because it can cause the account to be locked (and I also don't have tokens to test anymore).",
|
||||||
|
}),
|
||||||
|
);
|
||||||
const code = DataResolver.resolveInviteCode(invite);
|
const code = DataResolver.resolveInviteCode(invite);
|
||||||
if (!code) throw new Error('INVITE_RESOLVE_CODE');
|
if (!code) throw new Error('INVITE_RESOLVE_CODE');
|
||||||
const i = await this.fetchInvite(code);
|
const i = await this.fetchInvite(code);
|
||||||
|
|||||||
@@ -2,33 +2,32 @@
|
|||||||
|
|
||||||
const { Events, Opcodes, Status } = require('../../../util/Constants');
|
const { Events, Opcodes, Status } = require('../../../util/Constants');
|
||||||
|
|
||||||
// Receive messages in large guilds
|
|
||||||
const run = (client, guild) => {
|
const run = (client, guild) => {
|
||||||
if (!guild.large) return;
|
const subs = {};
|
||||||
client.ws.broadcast({
|
subs[guild.id] = {
|
||||||
op: Opcodes.GUILD_SUBSCRIPTIONS,
|
|
||||||
d: {
|
|
||||||
guild_id: guild.id,
|
|
||||||
typing: true,
|
typing: true,
|
||||||
threads: false,
|
threads: true,
|
||||||
activities: true,
|
activities: true,
|
||||||
|
member_updates: true,
|
||||||
thread_member_lists: [],
|
thread_member_lists: [],
|
||||||
members: [],
|
members: [],
|
||||||
channels: {
|
channels: {},
|
||||||
// [guild.channels.cache.first().id]: [[0, 99]],
|
};
|
||||||
},
|
client.ws.broadcast({
|
||||||
|
op: Opcodes.GUILD_SUBSCRIPTIONS_BULK,
|
||||||
|
d: {
|
||||||
|
subscriptions: subs,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = (client, { d: data }, shard) => {
|
module.exports = (client, { d: data }, shard) => {
|
||||||
let guild = client.guilds.cache.get(data.id);
|
let guild = client.guilds.cache.get(data.id);
|
||||||
|
run(client, data);
|
||||||
if (guild) {
|
if (guild) {
|
||||||
if (!guild.available && !data.unavailable) {
|
if (!guild.available && !data.unavailable) {
|
||||||
// A newly available guild
|
// A newly available guild
|
||||||
guild._patch(data);
|
guild._patch(data);
|
||||||
run(client, guild);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Emitted whenever a guild becomes available.
|
* Emitted whenever a guild becomes available.
|
||||||
* @event Client#guildAvailable
|
* @event Client#guildAvailable
|
||||||
|
|||||||
@@ -43,6 +43,45 @@ module.exports = (client, { d: data }, shard) => {
|
|||||||
// Todo: data.auth_session_id_hash
|
// Todo: data.auth_session_id_hash
|
||||||
|
|
||||||
if (data.guilds.length) {
|
if (data.guilds.length) {
|
||||||
|
if (data.guilds.length > 80) {
|
||||||
|
// Split data bc 15kb
|
||||||
|
const data1 = data.guilds.slice(0, Math.floor(data.guilds.length / 2));
|
||||||
|
const data2 = data.guilds.slice(Math.floor(data.guilds.length / 2));
|
||||||
|
client.ws.broadcast({
|
||||||
|
op: Opcodes.GUILD_SUBSCRIPTIONS_BULK,
|
||||||
|
d: {
|
||||||
|
subscriptions: data1.reduce((accumulator, guild) => {
|
||||||
|
accumulator[guild.id] = {
|
||||||
|
typing: true,
|
||||||
|
threads: true,
|
||||||
|
activities: true,
|
||||||
|
member_updates: true,
|
||||||
|
thread_member_lists: [],
|
||||||
|
members: [],
|
||||||
|
channels: {},
|
||||||
|
};
|
||||||
|
return accumulator;
|
||||||
|
}, {}),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
client.ws.broadcast({
|
||||||
|
op: Opcodes.GUILD_SUBSCRIPTIONS_BULK,
|
||||||
|
d: {
|
||||||
|
subscriptions: data2.reduce((accumulator, guild) => {
|
||||||
|
accumulator[guild.id] = {
|
||||||
|
typing: true,
|
||||||
|
threads: true,
|
||||||
|
activities: true,
|
||||||
|
member_updates: true,
|
||||||
|
thread_member_lists: [],
|
||||||
|
members: [],
|
||||||
|
channels: {},
|
||||||
|
};
|
||||||
|
return accumulator;
|
||||||
|
}, {}),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
client.ws.broadcast({
|
client.ws.broadcast({
|
||||||
op: Opcodes.GUILD_SUBSCRIPTIONS_BULK,
|
op: Opcodes.GUILD_SUBSCRIPTIONS_BULK,
|
||||||
d: {
|
d: {
|
||||||
@@ -61,6 +100,7 @@ module.exports = (client, { d: data }, shard) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Promise.all(
|
Promise.all(
|
||||||
data.private_channels.map(async (c, index) => {
|
data.private_channels.map(async (c, index) => {
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
const process = require('node:process');
|
const process = require('node:process');
|
||||||
const { Collection } = require('@discordjs/collection');
|
const { Collection } = require('@discordjs/collection');
|
||||||
const CachedManager = require('./CachedManager');
|
const CachedManager = require('./CachedManager');
|
||||||
const ThreadManager = require('./ThreadManager');
|
|
||||||
const { Error, TypeError } = require('../errors');
|
const { Error, TypeError } = require('../errors');
|
||||||
const GuildChannel = require('../structures/GuildChannel');
|
const GuildChannel = require('../structures/GuildChannel');
|
||||||
const PermissionOverwrites = require('../structures/PermissionOverwrites');
|
const PermissionOverwrites = require('../structures/PermissionOverwrites');
|
||||||
@@ -468,21 +467,6 @@ class GuildChannelManager extends CachedManager {
|
|||||||
}).guild;
|
}).guild;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Obtains all active thread channels in the guild from Discord
|
|
||||||
* @param {boolean} [cache=true] Whether to cache the fetched data
|
|
||||||
* @returns {Promise<FetchedThreads>}
|
|
||||||
* @example
|
|
||||||
* // Fetch all threads from the guild
|
|
||||||
* message.guild.channels.fetchActiveThreads()
|
|
||||||
* .then(fetched => console.log(`There are ${fetched.threads.size} threads.`))
|
|
||||||
* .catch(console.error);
|
|
||||||
*/
|
|
||||||
async fetchActiveThreads(cache = true) {
|
|
||||||
const raw = await this.client.api.guilds(this.guild.id).threads.active.get();
|
|
||||||
return ThreadManager._mapThreads(raw, this.client, { guild: this.guild, cache });
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the channel.
|
* Deletes the channel.
|
||||||
* @param {GuildChannelResolvable} channel The channel to delete
|
* @param {GuildChannelResolvable} channel The channel to delete
|
||||||
|
|||||||
@@ -162,7 +162,6 @@ class GuildManager extends CachedManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a guild.
|
* Creates a guild.
|
||||||
* <warn>This is only available to bots in fewer than 10 guilds.</warn>
|
|
||||||
* @param {string} name The name of the guild
|
* @param {string} name The name of the guild
|
||||||
* @param {GuildCreateOptions} [options] Options for creating the guild
|
* @param {GuildCreateOptions} [options] Options for creating the guild
|
||||||
* @returns {Promise<Guild>} The guild that was created
|
* @returns {Promise<Guild>} The guild that was created
|
||||||
@@ -238,6 +237,7 @@ class GuildManager extends CachedManager {
|
|||||||
afk_timeout: afkTimeout,
|
afk_timeout: afkTimeout,
|
||||||
system_channel_id: systemChannelId,
|
system_channel_id: systemChannelId,
|
||||||
system_channel_flags: systemChannelFlags,
|
system_channel_flags: systemChannelFlags,
|
||||||
|
guild_template_code: '2TffvPucqHkN', // From Discord
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -369,6 +369,7 @@ class User extends Base {
|
|||||||
return this.client.api.users(this.id).profile.get({
|
return this.client.api.users(this.id).profile.get({
|
||||||
query: {
|
query: {
|
||||||
with_mutual_guilds: true,
|
with_mutual_guilds: true,
|
||||||
|
with_mutual_friends: true,
|
||||||
with_mutual_friends_count: true,
|
with_mutual_friends_count: true,
|
||||||
guild_id: guildId,
|
guild_id: guildId,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -188,18 +188,12 @@ class Options extends null {
|
|||||||
referrer_current: '',
|
referrer_current: '',
|
||||||
referring_domain_current: '',
|
referring_domain_current: '',
|
||||||
release_channel: 'stable',
|
release_channel: 'stable',
|
||||||
client_build_number: 267220,
|
client_build_number: 306208,
|
||||||
client_event_source: null,
|
client_event_source: null,
|
||||||
},
|
},
|
||||||
compress: false,
|
compress: false,
|
||||||
client_state: {
|
client_state: {
|
||||||
guild_versions: {},
|
guild_versions: {},
|
||||||
highest_last_message_id: '0',
|
|
||||||
read_state_version: 0,
|
|
||||||
user_guild_settings_version: -1,
|
|
||||||
user_settings_version: -1,
|
|
||||||
private_channels_version: '0',
|
|
||||||
api_code_version: 0,
|
|
||||||
},
|
},
|
||||||
version: 9,
|
version: 9,
|
||||||
agent: {},
|
agent: {},
|
||||||
|
|||||||
2
typings/index.d.ts
vendored
2
typings/index.d.ts
vendored
@@ -777,6 +777,7 @@ export class Client<Ready extends boolean = boolean> extends BaseClient {
|
|||||||
/** @deprecated Use {@link Sweepers#sweepMessages} instead */
|
/** @deprecated Use {@link Sweepers#sweepMessages} instead */
|
||||||
public sweepMessages(lifetime?: number): number;
|
public sweepMessages(lifetime?: number): number;
|
||||||
public toJSON(): unknown;
|
public toJSON(): unknown;
|
||||||
|
/** @deprecated */
|
||||||
public acceptInvite(
|
public acceptInvite(
|
||||||
invite: InviteResolvable,
|
invite: InviteResolvable,
|
||||||
options?: AcceptInviteOptions,
|
options?: AcceptInviteOptions,
|
||||||
@@ -3934,7 +3935,6 @@ export class GuildChannelManager extends CachedManager<Snowflake, GuildBasedChan
|
|||||||
options?: SetChannelPositionOptions,
|
options?: SetChannelPositionOptions,
|
||||||
): Promise<GuildChannel>;
|
): Promise<GuildChannel>;
|
||||||
public setPositions(channelPositions: readonly ChannelPosition[]): Promise<Guild>;
|
public setPositions(channelPositions: readonly ChannelPosition[]): Promise<Guild>;
|
||||||
public fetchActiveThreads(cache?: boolean): Promise<FetchedThreads>;
|
|
||||||
public delete(channel: GuildChannelResolvable, reason?: string): Promise<void>;
|
public delete(channel: GuildChannelResolvable, reason?: string): Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user