Add group chat functions, slight refactoring

This commit is contained in:
Pedro Lopez
2019-02-20 02:42:19 -04:00
parent 594a65d5e8
commit 1b7376885d
12 changed files with 316 additions and 37 deletions

33
src/structures/Chat.js Normal file
View File

@@ -0,0 +1,33 @@
'use strict';
const Base = require('./Base');
/**
* Represents a Chat on WhatsApp
* @extends {Base}
*/
class Chat extends Base {
constructor(client, data) {
super(client);
if(data) this._patch(data);
}
_patch(data) {
this.id = data.id;
this.name = data.formattedTitle;
this.isGroup = data.isGroup;
this.isReadOnly = data.isReadOnly;
this.unreadCount = data.unreadCount;
this.timestamp = data.t;
return super._patch(data);
}
sendMessage(message) {
return this.client.sendMessage(this.id._serialized, message);
}
}
module.exports = Chat;