mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 03:53:29 +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 (options.lockPermissions) {
|
||||||
if (parent) {
|
if (parent) {
|
||||||
const newParent = this.guild.channels.resolve(parent);
|
const newParent = this.resolve(parent);
|
||||||
if (newParent?.type === ChannelType.GuildCategory) {
|
if (newParent?.type === ChannelType.GuildCategory) {
|
||||||
permission_overwrites = newParent.permissionOverwrites.cache.map(overwrite =>
|
permission_overwrites = newParent.permissionOverwrites.cache.map(overwrite =>
|
||||||
PermissionOverwrites.resolve(overwrite, this.guild),
|
PermissionOverwrites.resolve(overwrite, this.guild),
|
||||||
|
|||||||
@@ -535,7 +535,7 @@ class GuildMemberManager extends CachedManager {
|
|||||||
*/
|
*/
|
||||||
async addRole(options) {
|
async addRole(options) {
|
||||||
const { user, role, reason } = 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);
|
const roleId = this.guild.roles.resolveId(role);
|
||||||
await this.client.rest.put(Routes.guildMemberRole(this.guild.id, userId, roleId), { reason });
|
await this.client.rest.put(Routes.guildMemberRole(this.guild.id, userId, roleId), { reason });
|
||||||
|
|
||||||
@@ -549,7 +549,7 @@ class GuildMemberManager extends CachedManager {
|
|||||||
*/
|
*/
|
||||||
async removeRole(options) {
|
async removeRole(options) {
|
||||||
const { user, role, reason } = 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);
|
const roleId = this.guild.roles.resolveId(role);
|
||||||
await this.client.rest.delete(Routes.guildMemberRole(this.guild.id, userId, roleId), { reason });
|
await this.client.rest.delete(Routes.guildMemberRole(this.guild.id, userId, roleId), { reason });
|
||||||
|
|
||||||
|
|||||||
@@ -173,10 +173,7 @@ class GuildScheduledEventManager extends CachedManager {
|
|||||||
|
|
||||||
return data.reduce(
|
return data.reduce(
|
||||||
(coll, rawGuildScheduledEventData) =>
|
(coll, rawGuildScheduledEventData) =>
|
||||||
coll.set(
|
coll.set(rawGuildScheduledEventData.id, this._add(rawGuildScheduledEventData, options.cache)),
|
||||||
rawGuildScheduledEventData.id,
|
|
||||||
this.guild.scheduledEvents._add(rawGuildScheduledEventData, options.cache),
|
|
||||||
),
|
|
||||||
new Collection(),
|
new Collection(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user