mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 01:23:31 +01:00
prevent further user inaccuracies
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
const TextBasedChannel = require('./interface/TextBasedChannel');
|
||||
const Constants = require('../util/Constants');
|
||||
|
||||
function defined(p) {
|
||||
return typeof p !== 'undefined';
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a User on Discord.
|
||||
* @implements {TextBasedChannel}
|
||||
@@ -17,6 +21,24 @@ class User {
|
||||
if (data) this.setup(data);
|
||||
}
|
||||
|
||||
patch(data) {
|
||||
for (const item of ['id', 'username', 'discriminator', 'game', 'avatar']) {
|
||||
if (defined(data[item])) {
|
||||
this[item] = data[item];
|
||||
}
|
||||
}
|
||||
if (defined[data.bot]) {
|
||||
this.bot = data.bot;
|
||||
} else {
|
||||
this.bot = this.bot || false;
|
||||
}
|
||||
if (defined[data.status]) {
|
||||
this.status = data.status;
|
||||
} else {
|
||||
this.status = this.status || 'offline';
|
||||
}
|
||||
}
|
||||
|
||||
setup(data) {
|
||||
/**
|
||||
* The ID of the User
|
||||
@@ -36,13 +58,11 @@ class User {
|
||||
*/
|
||||
this.discriminator = data.discriminator;
|
||||
|
||||
if (typeof data.avatar !== 'undefined') {
|
||||
/**
|
||||
* The ID of the user's avatar
|
||||
* @type {string}
|
||||
*/
|
||||
this.avatar = data.avatar;
|
||||
}
|
||||
/**
|
||||
* The ID of the user's avatar
|
||||
* @type {string}
|
||||
*/
|
||||
this.avatar = data.avatar;
|
||||
|
||||
/**
|
||||
* Whether or not the User is a Bot.
|
||||
|
||||
Reference in New Issue
Block a user