fix(Partials): Use more user objects available from the gateway (#4791)

This commit is contained in:
MrWasdennnoch
2020-09-13 12:09:12 +02:00
committed by GitHub
parent bcb7c721dc
commit eeb4c14754
6 changed files with 71 additions and 60 deletions

View File

@@ -81,23 +81,23 @@ class GenericAction {
}
getMember(data, guild) {
const id = data.user.id;
return this.getPayload(
{
user: {
id,
},
},
guild.members,
id,
PartialTypes.GUILD_MEMBER,
);
return this.getPayload(data, guild.members, data.user.id, PartialTypes.GUILD_MEMBER);
}
getUser(data) {
const id = data.user_id;
return data.user || this.getPayload({ id }, this.client.users, id, PartialTypes.USER);
}
getUserFromMember(data) {
if (data.guild_id) {
const guild = this.client.guilds.cache.get(data.guild_id);
if (guild) {
return this.getMember(data.member, guild).user;
}
}
return this.getUser(data);
}
}
module.exports = GenericAction;