refactor(*): use async functions (#6210)

This commit is contained in:
Sugden
2021-08-02 00:47:43 +01:00
committed by GitHub
parent 626ff85ae7
commit e2e4f6518b
29 changed files with 298 additions and 399 deletions

View File

@@ -296,18 +296,17 @@ class GuildChannel extends Channel {
if (data.parent) data.parent = this.client.channels.resolveId(data.parent);
if (typeof data.position !== 'undefined') {
await Util.setPosition(
const updatedChannels = await Util.setPosition(
this,
data.position,
false,
this.guild._sortedChannels(this),
this.client.api.guilds(this.guild.id).channels,
reason,
).then(updatedChannels => {
this.client.actions.GuildChannelsPositionUpdate.handle({
guild_id: this.guild.id,
channels: updatedChannels,
});
);
this.client.actions.GuildChannelsPositionUpdate.handle({
guild_id: this.guild.id,
channels: updatedChannels,
});
}
@@ -389,8 +388,7 @@ class GuildChannel extends Channel {
setParent(channel, { lockPermissions = true, reason } = {}) {
return this.edit(
{
// eslint-disable-next-line no-prototype-builtins
parent: channel ?? null,
parentId: channel?.id ?? channel ?? null,
lockPermissions,
},
reason,
@@ -430,21 +428,20 @@ class GuildChannel extends Channel {
* .then(newChannel => console.log(`Channel's new position is ${newChannel.position}`))
* .catch(console.error);
*/
setPosition(position, { relative, reason } = {}) {
return Util.setPosition(
async setPosition(position, { relative, reason } = {}) {
const updatedChannels = await Util.setPosition(
this,
position,
relative,
this.guild._sortedChannels(this),
this.client.api.guilds(this.guild.id).channels,
reason,
).then(updatedChannels => {
this.client.actions.GuildChannelsPositionUpdate.handle({
guild_id: this.guild.id,
channels: updatedChannels,
});
return this;
);
this.client.actions.GuildChannelsPositionUpdate.handle({
guild_id: this.guild.id,
channels: updatedChannels,
});
return this;
}
/**
@@ -600,11 +597,9 @@ class GuildChannel extends Channel {
* .then(console.log)
* .catch(console.error);
*/
delete(reason) {
return this.client.api
.channels(this.id)
.delete({ reason })
.then(() => this);
async delete(reason) {
await this.client.api.channels(this.id).delete({ reason });
return this;
}
}