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

@@ -198,9 +198,10 @@ class GuildAuditLogs {
* Handles possible promises for entry targets.
* @returns {Promise<GuildAuditLogs>}
*/
static build(...args) {
static async build(...args) {
const logs = new GuildAuditLogs(...args);
return Promise.all(logs.entries.map(e => e.target)).then(() => logs);
await Promise.all(logs.entries.map(e => e.target));
return logs;
}
/**
@@ -500,19 +501,17 @@ class GuildAuditLogsEntry {
),
);
} else if (targetType === Targets.INVITE) {
this.target = guild.members.fetch(guild.client.user.id).then(me => {
this.target = guild.members.fetch(guild.client.user.id).then(async me => {
if (me.permissions.has(Permissions.FLAGS.MANAGE_GUILD)) {
let change = this.changes.find(c => c.key === 'code');
change = change.new ?? change.old;
return guild.invites.fetch().then(invites => {
this.target = invites.find(i => i.code === change) ?? null;
});
const invites = await guild.invites.fetch();
this.target = invites.find(i => i.code === change) ?? null;
} else {
this.target = this.changes.reduce((o, c) => {
o[c.key] = c.new ?? c.old;
return o;
}, {});
return this.target;
}
});
} else if (targetType === Targets.MESSAGE) {