mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 01:23:31 +01:00
3.3.0 - added TTS capability
This commit is contained in:
@@ -323,13 +323,19 @@ var Client = (function () {
|
||||
}
|
||||
}, {
|
||||
key: "reply",
|
||||
value: function reply(destination, message) {
|
||||
var callback = arguments.length <= 2 || arguments[2] === undefined ? function (err, msg) {} : arguments[2];
|
||||
value: function reply(destination, message, tts) {
|
||||
var callback = arguments.length <= 3 || arguments[3] === undefined ? function (err, msg) {} : arguments[3];
|
||||
|
||||
var self = this;
|
||||
|
||||
return new Promise(function (response, reject) {
|
||||
|
||||
if (typeof tts === "function") {
|
||||
// tts is a function, which means the developer wants this to be the callback
|
||||
callback = tts;
|
||||
tts = false;
|
||||
}
|
||||
|
||||
var user = destination.sender;
|
||||
self.sendMessage(destination, message, callback, user + ", ").then(response)["catch"](reject);
|
||||
});
|
||||
@@ -638,14 +644,20 @@ var Client = (function () {
|
||||
}
|
||||
}, {
|
||||
key: "sendMessage",
|
||||
value: function sendMessage(destination, message) {
|
||||
var callback = arguments.length <= 2 || arguments[2] === undefined ? function (err, msg) {} : arguments[2];
|
||||
var premessage = arguments.length <= 3 || arguments[3] === undefined ? "" : arguments[3];
|
||||
value: function sendMessage(destination, message, tts) {
|
||||
var callback = arguments.length <= 3 || arguments[3] === undefined ? function (err, msg) {} : arguments[3];
|
||||
var premessage = arguments.length <= 4 || arguments[4] === undefined ? "" : arguments[4];
|
||||
|
||||
var self = this;
|
||||
|
||||
var prom = new Promise(function (resolve, reject) {
|
||||
|
||||
if (typeof tts === "function") {
|
||||
// tts is a function, which means the developer wants this to be the callback
|
||||
callback = tts;
|
||||
tts = false;
|
||||
}
|
||||
|
||||
message = premessage + resolveMessage(message);
|
||||
var mentions = resolveMentions();
|
||||
self.resolveDestination(destination).then(send)["catch"](error);
|
||||
@@ -666,13 +678,14 @@ var Client = (function () {
|
||||
action: "sendMessage",
|
||||
content: message,
|
||||
mentions: mentions,
|
||||
tts: !!tts, //incase it's not a boolean
|
||||
then: mgood,
|
||||
error: mbad
|
||||
});
|
||||
|
||||
self.checkQueue(destination);
|
||||
} else {
|
||||
self._sendMessage(destination, message, mentions).then(mgood)["catch"](mbad);
|
||||
self._sendMessage(destination, message, tts, mentions).then(mgood)["catch"](mbad);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1393,14 +1406,15 @@ var Client = (function () {
|
||||
}
|
||||
}, {
|
||||
key: "_sendMessage",
|
||||
value: function _sendMessage(destination, content, mentions) {
|
||||
value: function _sendMessage(destination, content, tts, mentions) {
|
||||
|
||||
var self = this;
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
request.post(Endpoints.CHANNELS + "/" + destination + "/messages").set("authorization", self.token).send({
|
||||
content: content,
|
||||
mentions: mentions
|
||||
mentions: mentions,
|
||||
tts: tts
|
||||
}).end(function (err, res) {
|
||||
|
||||
if (err) {
|
||||
@@ -1520,7 +1534,7 @@ var Client = (function () {
|
||||
switch (queuedEvent.action) {
|
||||
case "sendMessage":
|
||||
var msgToSend = queuedEvent;
|
||||
self._sendMessage(channelID, msgToSend.content, msgToSend.mentions).then(function (msg) {
|
||||
self._sendMessage(channelID, msgToSend.content, msgToSend.tts, msgToSend.mentions).then(function (msg) {
|
||||
msgToSend.then(msg);
|
||||
self.queue[channelID].shift();
|
||||
doNext();
|
||||
|
||||
Reference in New Issue
Block a user