mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 08:33:30 +01:00
Added DM support, DM Creation and DM Deletion
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user