mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 01:23:31 +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;
|
||||
|
||||
@@ -19,7 +19,7 @@ class MessageCreateHandler extends AbstractHandler {
|
||||
let channel = client.store.get('channels', data.channel_id);
|
||||
|
||||
if (channel) {
|
||||
let message = new Message(channel, data);
|
||||
let message = new Message(channel, data, client);
|
||||
channel._cacheMessage(message);
|
||||
client.emit(Constants.Events.MESSAGE_CREATE, message);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user