Skip to content

Commit

Permalink
refactor: remove extra traversing (#10580)
Browse files Browse the repository at this point in the history
* refactor: remove extra traversion

* refactor(GuildScheduledEventManager): address fetch
  • Loading branch information
Jiralite authored Oct 25, 2024
1 parent 48a9c66 commit b932b64
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/discord.js/src/managers/GuildChannelManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions packages/discord.js/src/managers/GuildMemberManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });

Expand All @@ -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 });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
);
}
Expand Down

0 comments on commit b932b64

Please sign in to comment.