Added DM support, DM Creation and DM Deletion

This commit is contained in:
hydrabolt
2016-05-03 17:50:33 +01:00
parent ab17375248
commit bc443df11d
5 changed files with 75 additions and 14 deletions

View File

@@ -1,5 +1,7 @@
'use strict';
const TextBasedChannel = require('./interface/TextBasedChannel');
class GuildMember {
constructor(guild, data) {
this.client = guild.client;
@@ -56,6 +58,12 @@ class GuildMember {
get id() {
return this.user.id;
}
deleteDM() {
return this.client.rest.methods.DeleteChannel(this);
}
}
TextBasedChannel.applyToClass(GuildMember);
module.exports = GuildMember;

View File

@@ -1,5 +1,7 @@
'use strict';
const TextBasedChannel = require('./interface/TextBasedChannel');
class User {
constructor(client, data) {
this.client = client;
@@ -22,6 +24,10 @@ class User {
return `<@${this.id}>`;
}
deleteDM() {
return this.client.rest.methods.DeleteChannel(this);
}
equals(user) {
let base = (
this.username === user.username &&
@@ -45,4 +51,6 @@ class User {
}
}
TextBasedChannel.applyToClass(User);
module.exports = User;

View File

@@ -11,10 +11,5 @@ function sendTTSMessage(content, options) {
}
exports.applyToClass = structure => {
if (structure.name !== 'TextChannel' && structure.name !== 'DMChannel') {
throw new Error(structure + ' cannot implement TextBasedChannel');
}
structure.prototype.sendMessage = sendMessage;
};