mirror of
https://github.com/discordjs/discord.js.git
synced 2026-05-30 23:50:07 +00:00
49 lines
849 B
JavaScript
49 lines
849 B
JavaScript
'use strict';
|
|
|
|
class User {
|
|
constructor(client, data) {
|
|
this.client = client;
|
|
if (data) {
|
|
this.setup(data);
|
|
}
|
|
}
|
|
|
|
setup(data) {
|
|
this.username = data.username;
|
|
this.id = data.id;
|
|
this.discriminator = data.discriminator;
|
|
this.avatar = data.avatar;
|
|
this.bot = Boolean(data.bot);
|
|
this.status = data.status || this.status || 'offline';
|
|
this.game = data.game || this.game;
|
|
}
|
|
|
|
toString() {
|
|
return `<@${this.id}>`;
|
|
}
|
|
|
|
equals(user) {
|
|
let base = (
|
|
this.username === user.username &&
|
|
this.id === user.id &&
|
|
this.discriminator === user.discriminator &&
|
|
this.avatar === user.avatar &&
|
|
this.bot === Boolean(user.bot)
|
|
);
|
|
|
|
if (base) {
|
|
if (user.status) {
|
|
base = this.status === user.status;
|
|
}
|
|
|
|
if (user.game) {
|
|
base = this.game === user.game;
|
|
}
|
|
}
|
|
|
|
return base;
|
|
}
|
|
}
|
|
|
|
module.exports = User;
|