Add Message Deletion via message.delete()

This commit is contained in:
hydrabolt
2016-04-21 18:50:46 +01:00
parent a2841f285c
commit c42e303b7b
4 changed files with 20 additions and 3 deletions

View File

@@ -3,7 +3,7 @@
- [x] sending tts messages
- [ ] sending files
- [ ] updating user details
- [ ] deleting messages
- [x] deleting messages
- [ ] updating messages
- [ ] leaving guilds
- [ ] deleting guilds

View File

@@ -50,6 +50,16 @@ class RESTMethods{
.catch(reject);
});
}
DeleteMessage(channel, message) {
return new Promise((resolve, reject) => {
this.rest.makeRequest('del', Constants.Endpoints.CHANNEL_MESSAGE(channel.id, message.id), true)
.then(() => {
resolve(message);
})
.catch(reject);
});
}
}
module.exports = RESTMethods;

View File

@@ -71,6 +71,10 @@ class Message {
if (data.id)
this.id = data.id;
}
delete() {
return this.client.rest.methods.DeleteMessage(this.channel, this);
}
}
module.exports = Message;

View File

@@ -69,8 +69,11 @@ client.on('typingStop.', (channel, user, data) => {
});
client.on('message', message => {
if (message.author.username === 'hydrabolt')
message.channel.sendMessage('hydrabolt said: ' + message.content).then(m => console.log(m.content)).catch(console.log);
if (message.author.username === 'hydrabolt') {
message.channel.sendMessage('test').then(msg => {
msg.delete();
});
}
});
client.on('messageDelete', message => {