fix(GuildAuditLog): Remove Promises in constructor (#7089)

This commit is contained in:
Jiralite
2021-12-14 18:03:21 +00:00
committed by GitHub
parent 2ce244b502
commit 9cf44d1c0e
3 changed files with 45 additions and 17 deletions

View File

@@ -7,6 +7,8 @@ const { Error } = require('../errors');
const { Endpoints } = require('../util/Constants');
const Permissions = require('../util/Permissions');
// TODO: Convert `inviter` and `channel` in this class to a getter.
/**
* Represents an invitation to a guild channel.
* @extends {Base}
@@ -106,12 +108,24 @@ class Invite extends Base {
this.maxUses ??= null;
}
if ('inviter_id' in data) {
/**
* The user's id who created this invite
* @type {?Snowflake}
*/
this.inviterId = data.inviter_id;
this.inviter = this.client.users.resolve(data.inviter_id);
} else {
this.inviterId ??= null;
}
if ('inviter' in data) {
/**
* The user who created this invite
* @type {?User}
*/
this.inviter = this.client.users._add(data.inviter);
this.inviter ??= this.client.users._add(data.inviter);
this.inviterId = data.inviter.id;
} else {
this.inviter ??= null;
}
@@ -154,12 +168,22 @@ class Invite extends Base {
this.targetType ??= null;
}
if ('channel_id' in data) {
/**
* The channel's id this invite is for
* @type {Snowflake}
*/
this.channelId = data.channel_id;
this.channel = this.client.channels.cache.get(data.channel_id);
}
if ('channel' in data) {
/**
* The channel this invite is for
* @type {Channel}
*/
this.channel = this.client.channels._add(data.channel, this.guild, { cache: false });
this.channel ??= this.client.channels._add(data.channel, this.guild, { cache: false });
this.channelId ??= data.channel.id;
}
if ('created_at' in data) {