Skip to content

Commit 9461045

Browse files
refactor(GuildChannelManager): Remove redundant edit code (#10370)
refactor(GuildChannelManager): remove redundant edit code Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent 3654efe commit 9461045

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

packages/discord.js/src/managers/GuildChannelManager.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,13 @@ class GuildChannelManager extends CachedManager {
284284
* .catch(console.error);
285285
*/
286286
async edit(channel, options) {
287-
channel = this.resolve(channel);
288-
if (!channel) throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'channel', 'GuildChannelResolvable');
287+
const resolvedChannel = this.resolve(channel);
288+
if (!resolvedChannel) throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'channel', 'GuildChannelResolvable');
289289

290290
const parent = options.parent && this.client.channels.resolveId(options.parent);
291291

292292
if (options.position !== undefined) {
293-
await this.setPosition(channel, options.position, { position: options.position, reason: options.reason });
293+
await this.setPosition(resolvedChannel, options.position, { position: options.position, reason: options.reason });
294294
}
295295

296296
let permission_overwrites = options.permissionOverwrites?.map(overwrite =>
@@ -305,22 +305,22 @@ class GuildChannelManager extends CachedManager {
305305
PermissionOverwrites.resolve(overwrite, this.guild),
306306
);
307307
}
308-
} else if (channel.parent) {
309-
permission_overwrites = channel.parent.permissionOverwrites.cache.map(overwrite =>
308+
} else if (resolvedChannel.parent) {
309+
permission_overwrites = resolvedChannel.parent.permissionOverwrites.cache.map(overwrite =>
310310
PermissionOverwrites.resolve(overwrite, this.guild),
311311
);
312312
}
313313
}
314314

315-
const newData = await this.client.rest.patch(Routes.channel(channel.id), {
315+
const newData = await this.client.rest.patch(Routes.channel(resolvedChannel.id), {
316316
body: {
317-
name: (options.name ?? channel.name).trim(),
317+
name: options.name,
318318
type: options.type,
319319
topic: options.topic,
320320
nsfw: options.nsfw,
321-
bitrate: options.bitrate ?? channel.bitrate,
322-
user_limit: options.userLimit ?? channel.userLimit,
323-
rtc_region: 'rtcRegion' in options ? options.rtcRegion : channel.rtcRegion,
321+
bitrate: options.bitrate,
322+
user_limit: options.userLimit,
323+
rtc_region: options.rtcRegion,
324324
video_quality_mode: options.videoQualityMode,
325325
parent_id: parent,
326326
lock_permissions: options.lockPermissions,

0 commit comments

Comments
 (0)