mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 16:43:31 +01:00
add .toObject() method to structures (#522)
* add .toObject() method to structures * add compiled PMChannel change from last commit * uncomment members in VoiceChannel toObject method
This commit is contained in:
@@ -51,6 +51,36 @@ var User = (function (_Equality) {
|
||||
return this.mention();
|
||||
};
|
||||
|
||||
User.prototype.toObject = function toObject() {
|
||||
var keys = ['id', 'username', 'discriminator', 'avatar', 'bot', 'status', 'game', 'note', 'voiceState', 'speaking'],
|
||||
obj = {};
|
||||
|
||||
for (var _iterator = keys, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
|
||||
var _ref;
|
||||
|
||||
if (_isArray) {
|
||||
if (_i >= _iterator.length) break;
|
||||
_ref = _iterator[_i++];
|
||||
} else {
|
||||
_i = _iterator.next();
|
||||
if (_i.done) break;
|
||||
_ref = _i.value;
|
||||
}
|
||||
|
||||
var k = _ref;
|
||||
|
||||
obj[k] = this[k];
|
||||
}
|
||||
|
||||
obj.typing = {
|
||||
since: this.typing.since,
|
||||
channelID: this.typing.channel ? this.typing.channel.id : null
|
||||
};
|
||||
obj.voiceChannelID = this.voiceChannel ? this.voiceChannel.id : null;
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
User.prototype.equalsStrict = function equalsStrict(obj) {
|
||||
if (obj instanceof User) return this.id === obj.id && this.username === obj.username && this.discriminator === obj.discriminator && this.avatar === obj.avatar && this.status === obj.status && (this.game === obj.game || this.game && obj.game && this.game.name === obj.game.name);else return false;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user