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('BAN_MEMBERS') ||
|
||||||
this.guild.me.permissions.has('MANAGE_ROLES')
|
this.guild.me.permissions.has('MANAGE_ROLES')
|
||||||
) {
|
) {
|
||||||
type = 8; // This is opcode
|
type = Opcodes.REQUEST_GUILD_MEMBERS; // This is opcode
|
||||||
this.guild.shard.send({
|
this.guild.shard.send({
|
||||||
op: Opcodes.REQUEST_GUILD_MEMBERS,
|
op: type,
|
||||||
d: {
|
d: {
|
||||||
guild_id: this.guild.id,
|
guild_id: this.guild.id,
|
||||||
presences,
|
presences,
|
||||||
@ -440,7 +440,7 @@ class GuildMemberManager extends CachedManager {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
type = 14; // This is opcode
|
type = Opcodes.LAZY_REQUEST; // This is opcode
|
||||||
let channel;
|
let channel;
|
||||||
let channels = this.guild.channels.cache.filter(c => c.isText());
|
let channels = this.guild.channels.cache.filter(c => c.isText());
|
||||||
channels = channels.filter(c => c.permissionsFor(this.guild.me).has('VIEW_CHANNEL'));
|
channels = channels.filter(c => c.permissionsFor(this.guild.me).has('VIEW_CHANNEL'));
|
||||||
@ -468,6 +468,14 @@ class GuildMemberManager extends CachedManager {
|
|||||||
[200, 299],
|
[200, 299],
|
||||||
]);
|
]);
|
||||||
} else {
|
} 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;
|
let x = 100;
|
||||||
for (let i = 0; i < allMember; i++) {
|
for (let i = 0; i < allMember; i++) {
|
||||||
if (x > allMember) {
|
if (x > allMember) {
|
||||||
@ -485,7 +493,7 @@ class GuildMemberManager extends CachedManager {
|
|||||||
Promise.all(
|
Promise.all(
|
||||||
list.map(l => {
|
list.map(l => {
|
||||||
this.guild.shard.send({
|
this.guild.shard.send({
|
||||||
op: Opcodes.LAZY_REQUEST,
|
op: type,
|
||||||
d: {
|
d: {
|
||||||
guild_id: this.guild.id,
|
guild_id: this.guild.id,
|
||||||
typing: true,
|
typing: true,
|
||||||
@ -516,7 +524,7 @@ class GuildMemberManager extends CachedManager {
|
|||||||
this.client.decrementMaxListeners();
|
this.client.decrementMaxListeners();
|
||||||
let fetched = fetchedMembers.size < this.guild.members.cache.size ? this.guild.members.cache : fetchedMembers;
|
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 (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));
|
this.guild.client.sleep(sleepTime).then(() => resolve(fetched));
|
||||||
} else {
|
} else {
|
||||||
resolve(fetched);
|
resolve(fetched);
|
||||||
|
@ -630,6 +630,7 @@ class ApplicationCommand extends Base {
|
|||||||
type: ApplicationCommandTypes[this.type],
|
type: ApplicationCommandTypes[this.type],
|
||||||
options: option_,
|
options: option_,
|
||||||
},
|
},
|
||||||
|
nonce: SnowflakeUtil.generate(),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
@ -666,6 +667,7 @@ class ApplicationCommand extends Base {
|
|||||||
type: ApplicationCommandTypes[this.type],
|
type: ApplicationCommandTypes[this.type],
|
||||||
target_id: ApplicationCommandTypes[this.type] == 1 ? message.author.id : message.id,
|
target_id: ApplicationCommandTypes[this.type] == 1 ? message.author.id : message.id,
|
||||||
},
|
},
|
||||||
|
nonce: SnowflakeUtil.generate(),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
|
@ -638,7 +638,7 @@ class Guild extends AnonymousGuild {
|
|||||||
// MODAL_SUMMIT :))
|
// MODAL_SUMMIT :))
|
||||||
}
|
}
|
||||||
if (type < 1 || type > 3) {
|
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') {
|
if (typeof type !== 'number') {
|
||||||
throw new TypeError('Type must be a number | string');
|
throw new TypeError('Type must be a number | string');
|
||||||
|
@ -4,6 +4,7 @@ const BaseMessageComponent = require('./BaseMessageComponent');
|
|||||||
const { Message } = require('./Message');
|
const { Message } = require('./Message');
|
||||||
const { RangeError } = require('../errors');
|
const { RangeError } = require('../errors');
|
||||||
const { MessageButtonStyles, MessageComponentTypes } = require('../util/Constants');
|
const { MessageButtonStyles, MessageComponentTypes } = require('../util/Constants');
|
||||||
|
const SnowflakeUtil = require('../util/SnowflakeUtil');
|
||||||
const Util = require('../util/Util');
|
const Util = require('../util/Util');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -183,6 +184,7 @@ class MessageButton extends BaseMessageComponent {
|
|||||||
component_type: 2, // Button
|
component_type: 2, // Button
|
||||||
custom_id: this.customId,
|
custom_id: this.customId,
|
||||||
},
|
},
|
||||||
|
nonce: SnowflakeUtil.generate(),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
const BaseMessageComponent = require('./BaseMessageComponent');
|
const BaseMessageComponent = require('./BaseMessageComponent');
|
||||||
const { Message } = require('./Message');
|
const { Message } = require('./Message');
|
||||||
const { MessageComponentTypes } = require('../util/Constants');
|
const { MessageComponentTypes } = require('../util/Constants');
|
||||||
|
const SnowflakeUtil = require('../util/SnowflakeUtil');
|
||||||
const Util = require('../util/Util');
|
const Util = require('../util/Util');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -254,6 +255,7 @@ class MessageSelectMenu extends BaseMessageComponent {
|
|||||||
type: 3, // Select Menu
|
type: 3, // Select Menu
|
||||||
values,
|
values,
|
||||||
},
|
},
|
||||||
|
nonce: SnowflakeUtil.generate(),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user