mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 09:03:29 +01:00
add channel.sendMessage and channel.sendTTSMessage
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const Constants = require('../../util/Constants');
|
||||
const Structure = name => require('../../structures/' + name);
|
||||
|
||||
const Message = Structure('Message');
|
||||
|
||||
class RESTMethods{
|
||||
constructor(restManager) {
|
||||
@@ -32,6 +35,21 @@ class RESTMethods{
|
||||
.catch(reject);
|
||||
});
|
||||
}
|
||||
|
||||
SendMessage(channel, content, tts, nonce) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.rest.makeRequest('post', Constants.Endpoints.CHANNEL_MESSAGES(channel.id), true, {
|
||||
content, tts, nonce,
|
||||
})
|
||||
.then(data => {
|
||||
let message = new Message(channel, data, this.rest.client);
|
||||
channel._cacheMessage(message);
|
||||
resolve(message);
|
||||
this.rest.client.emit(Constants.Events.MESSAGE_CREATE, message);
|
||||
})
|
||||
.catch(reject);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = RESTMethods;
|
||||
|
||||
Reference in New Issue
Block a user