perf: use logical assignments instead of if statements (#6693)

This commit is contained in:
Almeida
2021-10-03 13:59:57 +01:00
committed by GitHub
parent 9eb9591473
commit e9daa31eaf
9 changed files with 17 additions and 21 deletions

View File

@@ -294,7 +294,7 @@ class GuildChannel extends Channel {
* .catch(console.error);
*/
async edit(data, reason) {
if (data.parent) data.parent = this.client.channels.resolveId(data.parent);
data.parent &&= this.client.channels.resolveId(data.parent);
if (typeof data.position !== 'undefined') {
const updatedChannels = await Util.setPosition(

View File

@@ -245,7 +245,7 @@ class Webhook {
if (avatar && !(typeof avatar === 'string' && avatar.startsWith('data:'))) {
avatar = await DataResolver.resolveImage(avatar);
}
if (channel) channel = channel?.id ?? channel;
channel &&= channel.id ?? channel;
const data = await this.client.api.webhooks(this.id, channel ? undefined : this.token).patch({
data: { name, avatar, channel_id: channel },
reason,