mirror of
https://github.com/discordjs/discord.js.git
synced 2024-08-21 20:04:45 +12:00
refactor(GuildChannelManager): remove redundant edit code
This commit is contained in:
parent
ab8bf0f4d2
commit
fdd1fb3fea
1 changed files with 10 additions and 10 deletions
|
@ -284,13 +284,13 @@ class GuildChannelManager extends CachedManager {
|
||||||
* .catch(console.error);
|
* .catch(console.error);
|
||||||
*/
|
*/
|
||||||
async edit(channel, options) {
|
async edit(channel, options) {
|
||||||
channel = this.resolve(channel);
|
const resolvedChannel = this.resolve(channel);
|
||||||
if (!channel) throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'channel', 'GuildChannelResolvable');
|
if (!resolvedChannel) throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'channel', 'GuildChannelResolvable');
|
||||||
|
|
||||||
const parent = options.parent && this.client.channels.resolveId(options.parent);
|
const parent = options.parent && this.client.channels.resolveId(options.parent);
|
||||||
|
|
||||||
if (options.position !== undefined) {
|
if (options.position !== undefined) {
|
||||||
await this.setPosition(channel, options.position, { position: options.position, reason: options.reason });
|
await this.setPosition(resolvedChannel, options.position, { position: options.position, reason: options.reason });
|
||||||
}
|
}
|
||||||
|
|
||||||
let permission_overwrites = options.permissionOverwrites?.map(overwrite =>
|
let permission_overwrites = options.permissionOverwrites?.map(overwrite =>
|
||||||
|
@ -305,22 +305,22 @@ class GuildChannelManager extends CachedManager {
|
||||||
PermissionOverwrites.resolve(overwrite, this.guild),
|
PermissionOverwrites.resolve(overwrite, this.guild),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else if (channel.parent) {
|
} else if (resolvedChannel.parent) {
|
||||||
permission_overwrites = channel.parent.permissionOverwrites.cache.map(overwrite =>
|
permission_overwrites = resolvedChannel.parent.permissionOverwrites.cache.map(overwrite =>
|
||||||
PermissionOverwrites.resolve(overwrite, this.guild),
|
PermissionOverwrites.resolve(overwrite, this.guild),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const newData = await this.client.rest.patch(Routes.channel(channel.id), {
|
const newData = await this.client.rest.patch(Routes.channel(resolvedChannel.id), {
|
||||||
body: {
|
body: {
|
||||||
name: (options.name ?? channel.name).trim(),
|
name: options.name,
|
||||||
type: options.type,
|
type: options.type,
|
||||||
topic: options.topic,
|
topic: options.topic,
|
||||||
nsfw: options.nsfw,
|
nsfw: options.nsfw,
|
||||||
bitrate: options.bitrate ?? channel.bitrate,
|
bitrate: options.bitrate,
|
||||||
user_limit: options.userLimit ?? channel.userLimit,
|
user_limit: options.userLimit,
|
||||||
rtc_region: 'rtcRegion' in options ? options.rtcRegion : channel.rtcRegion,
|
rtc_region: options.rtcRegion,
|
||||||
video_quality_mode: options.videoQualityMode,
|
video_quality_mode: options.videoQualityMode,
|
||||||
parent_id: parent,
|
parent_id: parent,
|
||||||
lock_permissions: options.lockPermissions,
|
lock_permissions: options.lockPermissions,
|
||||||
|
|
Loading…
Reference in a new issue