Update
- Warn msg - Add `nonce` param (interaction)
This commit is contained in:
parent
057f6ae3ad
commit
83ce0a0f43
@ -1 +0,0 @@
|
||||
|
@ -427,9 +427,9 @@ class GuildMemberManager extends CachedManager {
|
||||
this.guild.me.permissions.has('BAN_MEMBERS') ||
|
||||
this.guild.me.permissions.has('MANAGE_ROLES')
|
||||
) {
|
||||
type = 8; // This is opcode
|
||||
type = Opcodes.REQUEST_GUILD_MEMBERS; // This is opcode
|
||||
this.guild.shard.send({
|
||||
op: Opcodes.REQUEST_GUILD_MEMBERS,
|
||||
op: type,
|
||||
d: {
|
||||
guild_id: this.guild.id,
|
||||
presences,
|
||||
@ -440,7 +440,7 @@ class GuildMemberManager extends CachedManager {
|
||||
},
|
||||
});
|
||||
} else {
|
||||
type = 14; // This is opcode
|
||||
type = Opcodes.LAZY_REQUEST; // This is opcode
|
||||
let channel;
|
||||
let channels = this.guild.channels.cache.filter(c => c.isText());
|
||||
channels = channels.filter(c => c.permissionsFor(this.guild.me).has('VIEW_CHANNEL'));
|
||||
@ -468,6 +468,14 @@ class GuildMemberManager extends CachedManager {
|
||||
[200, 299],
|
||||
]);
|
||||
} else {
|
||||
if (allMember > 1_000) {
|
||||
console.warn(
|
||||
`[WARN] Guild ${this.guild.id} has ${allMember} > 1000 members. Can't get offline members (Opcode 14)\n> https://discordpy-self.readthedocs.io/en/latest/migrating_from_dpy.html#guild-members`,
|
||||
);
|
||||
if (allMember > 75_000) {
|
||||
console.warn(`[WARN] Can't get enough members because the guild is large (Opcode 14)`);
|
||||
}
|
||||
}
|
||||
let x = 100;
|
||||
for (let i = 0; i < allMember; i++) {
|
||||
if (x > allMember) {
|
||||
@ -485,7 +493,7 @@ class GuildMemberManager extends CachedManager {
|
||||
Promise.all(
|
||||
list.map(l => {
|
||||
this.guild.shard.send({
|
||||
op: Opcodes.LAZY_REQUEST,
|
||||
op: type,
|
||||
d: {
|
||||
guild_id: this.guild.id,
|
||||
typing: true,
|
||||
@ -516,7 +524,7 @@ class GuildMemberManager extends CachedManager {
|
||||
this.client.decrementMaxListeners();
|
||||
let fetched = fetchedMembers.size < this.guild.members.cache.size ? this.guild.members.cache : fetchedMembers;
|
||||
if (user_ids && !Array.isArray(user_ids) && fetched.size) fetched = fetched.first();
|
||||
if (type == 14) {
|
||||
if (type == Opcodes.LAZY_REQUEST) {
|
||||
this.guild.client.sleep(sleepTime).then(() => resolve(fetched));
|
||||
} else {
|
||||
resolve(fetched);
|
||||
|
@ -630,6 +630,7 @@ class ApplicationCommand extends Base {
|
||||
type: ApplicationCommandTypes[this.type],
|
||||
options: option_,
|
||||
},
|
||||
nonce: SnowflakeUtil.generate(),
|
||||
},
|
||||
});
|
||||
return true;
|
||||
@ -666,6 +667,7 @@ class ApplicationCommand extends Base {
|
||||
type: ApplicationCommandTypes[this.type],
|
||||
target_id: ApplicationCommandTypes[this.type] == 1 ? message.author.id : message.id,
|
||||
},
|
||||
nonce: SnowflakeUtil.generate(),
|
||||
},
|
||||
});
|
||||
return true;
|
||||
|
@ -638,7 +638,7 @@ class Guild extends AnonymousGuild {
|
||||
// MODAL_SUMMIT :))
|
||||
}
|
||||
if (type < 1 || type > 3) {
|
||||
throw new RangeError('Type must be 1, 2, 3');
|
||||
throw new RangeError('Type must be 1 (CHAT_INPUT), 2 (USER), 3 (MESSAGE)');
|
||||
}
|
||||
if (typeof type !== 'number') {
|
||||
throw new TypeError('Type must be a number | string');
|
||||
|
@ -4,6 +4,7 @@ const BaseMessageComponent = require('./BaseMessageComponent');
|
||||
const { Message } = require('./Message');
|
||||
const { RangeError } = require('../errors');
|
||||
const { MessageButtonStyles, MessageComponentTypes } = require('../util/Constants');
|
||||
const SnowflakeUtil = require('../util/SnowflakeUtil');
|
||||
const Util = require('../util/Util');
|
||||
|
||||
/**
|
||||
@ -183,6 +184,7 @@ class MessageButton extends BaseMessageComponent {
|
||||
component_type: 2, // Button
|
||||
custom_id: this.customId,
|
||||
},
|
||||
nonce: SnowflakeUtil.generate(),
|
||||
},
|
||||
});
|
||||
return true;
|
||||
|
@ -3,6 +3,7 @@
|
||||
const BaseMessageComponent = require('./BaseMessageComponent');
|
||||
const { Message } = require('./Message');
|
||||
const { MessageComponentTypes } = require('../util/Constants');
|
||||
const SnowflakeUtil = require('../util/SnowflakeUtil');
|
||||
const Util = require('../util/Util');
|
||||
|
||||
/**
|
||||
@ -254,6 +255,7 @@ class MessageSelectMenu extends BaseMessageComponent {
|
||||
type: 3, // Select Menu
|
||||
values,
|
||||
},
|
||||
nonce: SnowflakeUtil.generate(),
|
||||
},
|
||||
});
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user