Beginning to move send message functions to unified function

This commit is contained in:
hydrabolt
2015-08-29 16:30:25 +01:00
parent 8a1f99b049
commit c14b2fafb6
2 changed files with 170 additions and 226 deletions

View File

@@ -625,40 +625,11 @@ class Client {
if(self.options.queue){
//we're QUEUEING messages, so sending them sequentially based on servers.
self.addMessageQueue(destination);
}else{
self._sendMessage("text", destination, message, mentions);
}
request
.post(`${Endpoints.CHANNELS}/${destination}/messages`)
.set("authorization", self.token)
.send({
content: message,
mentions: mentions
})
.end(function (err, res) {
if (err) {
callback(err);
reject(err);
} else {
var data = res.body;
var mentions = [];
data.mentions = data.mentions || []; //for some reason this was not defined at some point?
for (var mention of data.mentions) {
mentions.push(self.addUser(mention));
}
var channel = self.getChannel("id", data.channel_id);
if (channel) {
var msg = channel.addMessage(new Message(data, channel, mentions, self.addUser(data.author)));
callback(null, msg);
resolve(msg);
}
}
});
}
function resolveMessage() {
@@ -1118,6 +1089,16 @@ class Client {
resolve(channId);
});
}
_sendMessage(messageType, destination, content, mentions){
var self = this;
return new Promise(function(resolve, reject){
});
}
}