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:
Brian Tanner
2016-08-16 23:53:07 +07:00
committed by abal
parent e42178181d
commit fdfd41dd8c
21 changed files with 426 additions and 58 deletions

View File

@@ -58,6 +58,22 @@ export default class Message extends Equality{
return this.author;
}
toObject() {
let keys = ['id', 'timestamp', 'everyoneMentioned', 'pinned', 'editedTimestamp', 'content', 'cleanContent', 'tts', 'attachments', 'embeds'],
obj = {};
for (let k of keys) {
obj[k] = this[k];
}
obj.channelID = this.channel ? this.channel.id : null;
obj.serverID = this.server ? this.server.id : null;
obj.author = this.author.toObject();
obj.mentions = this.mentions.map(m => m.toObject());
return obj;
}
isMentioned(user){
user = this.client.internal.resolver.resolveUser(user);
if (!user) {