mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
refactor: remove extra traversing (#10580)
* refactor: remove extra traversion * refactor(GuildScheduledEventManager): address fetch
This commit is contained in:
@@ -299,7 +299,7 @@ class GuildChannelManager extends CachedManager {
|
||||
|
||||
if (options.lockPermissions) {
|
||||
if (parent) {
|
||||
const newParent = this.guild.channels.resolve(parent);
|
||||
const newParent = this.resolve(parent);
|
||||
if (newParent?.type === ChannelType.GuildCategory) {
|
||||
permission_overwrites = newParent.permissionOverwrites.cache.map(overwrite =>
|
||||
PermissionOverwrites.resolve(overwrite, this.guild),
|
||||
|
||||
@@ -535,7 +535,7 @@ class GuildMemberManager extends CachedManager {
|
||||
*/
|
||||
async addRole(options) {
|
||||
const { user, role, reason } = options;
|
||||
const userId = this.guild.members.resolveId(user);
|
||||
const userId = this.resolveId(user);
|
||||
const roleId = this.guild.roles.resolveId(role);
|
||||
await this.client.rest.put(Routes.guildMemberRole(this.guild.id, userId, roleId), { reason });
|
||||
|
||||
@@ -549,7 +549,7 @@ class GuildMemberManager extends CachedManager {
|
||||
*/
|
||||
async removeRole(options) {
|
||||
const { user, role, reason } = options;
|
||||
const userId = this.guild.members.resolveId(user);
|
||||
const userId = this.resolveId(user);
|
||||
const roleId = this.guild.roles.resolveId(role);
|
||||
await this.client.rest.delete(Routes.guildMemberRole(this.guild.id, userId, roleId), { reason });
|
||||
|
||||
|
||||
@@ -173,10 +173,7 @@ class GuildScheduledEventManager extends CachedManager {
|
||||
|
||||
return data.reduce(
|
||||
(coll, rawGuildScheduledEventData) =>
|
||||
coll.set(
|
||||
rawGuildScheduledEventData.id,
|
||||
this.guild.scheduledEvents._add(rawGuildScheduledEventData, options.cache),
|
||||
),
|
||||
coll.set(rawGuildScheduledEventData.id, this._add(rawGuildScheduledEventData, options.cache)),
|
||||
new Collection(),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user