discord.js
Advanced tools
Comparing version 3.3.2 to 3.3.3
@@ -67,3 +67,3 @@ "use strict"; | ||
value: function toString() { | ||
return "#" + this.name; | ||
return "<#" + this.id + ">"; | ||
} | ||
@@ -70,0 +70,0 @@ }, { |
@@ -151,3 +151,3 @@ //discord.js modules | ||
getGateway().then(function (url) { | ||
self.getGateway().then(function (url) { | ||
self.createws(url); | ||
@@ -341,3 +341,3 @@ callback(null, self.token); | ||
var user = destination.sender; | ||
self.sendMessage(destination, message, callback, user + ", ").then(response)["catch"](reject); | ||
self.sendMessage(destination, message, tts, callback, user + ", ").then(response)["catch"](reject); | ||
}); | ||
@@ -1606,2 +1606,16 @@ } | ||
}, { | ||
key: "getGateway", | ||
value: function getGateway() { | ||
var self = this; | ||
return new Promise(function (resolve, reject) { | ||
request.get(Endpoints.API + "/gateway").set("authorization", self.token).end(function (err, res) { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(res.body.url); | ||
} | ||
}); | ||
}); | ||
} | ||
}, { | ||
key: "uptime", | ||
@@ -1674,17 +1688,2 @@ get: function get() { | ||
function getGateway() { | ||
var self = this; | ||
return new Promise(function (resolve, reject) { | ||
request.get(Endpoints.API + "/gateway").end(function (err, res) { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(res.body.url); | ||
} | ||
}); | ||
}); | ||
} | ||
module.exports = Client; |
@@ -168,2 +168,7 @@ "use strict"; | ||
} | ||
}, { | ||
key: "users", | ||
get: function get() { | ||
return this.members; | ||
} | ||
}]); | ||
@@ -170,0 +175,0 @@ |
{ | ||
"name": "discord.js", | ||
"version": "3.3.2", | ||
"version": "3.3.3", | ||
"description": "A way to interface with the Discord API", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -37,3 +37,3 @@ class Channel { | ||
toString(){ | ||
return "#" + this.name; | ||
return "<#" + this.id + ">"; | ||
} | ||
@@ -40,0 +40,0 @@ |
@@ -156,3 +156,3 @@ //discord.js modules | ||
self.trigger("disconnected"); | ||
if(self.websocket){ | ||
if (self.websocket) { | ||
self.websocket.close(); | ||
@@ -166,3 +166,3 @@ } | ||
getGateway().then(function (url) { | ||
self.getGateway().then(function (url) { | ||
self.createws(url); | ||
@@ -372,3 +372,3 @@ callback(null, self.token); | ||
if(typeof tts === "function"){ | ||
if (typeof tts === "function") { | ||
// tts is a function, which means the developer wants this to be the callback | ||
@@ -380,3 +380,3 @@ callback = tts; | ||
var user = destination.sender; | ||
self.sendMessage(destination, message, callback, user + ", ").then(response).catch(reject); | ||
self.sendMessage(destination, message, tts, callback, user + ", ").then(response).catch(reject); | ||
@@ -390,3 +390,3 @@ }); | ||
var self = this; | ||
var prom = new Promise(function (resolve, reject) { | ||
@@ -400,3 +400,3 @@ if (timeout) { | ||
function remove() { | ||
if(self.options.queue){ | ||
if (self.options.queue) { | ||
if (!self.queue[message.channel.id]) { | ||
@@ -411,10 +411,10 @@ self.queue[message.channel.id] = []; | ||
}); | ||
self.checkQueue(message.channel.id); | ||
}else{ | ||
} else { | ||
self._deleteMessage(message).then(good).catch(bad); | ||
} | ||
} | ||
function good(){ | ||
function good() { | ||
prom.success = true; | ||
@@ -424,4 +424,4 @@ callback(null); | ||
} | ||
function bad(err){ | ||
function bad(err) { | ||
prom.error = err; | ||
@@ -432,3 +432,3 @@ callback(err); | ||
}); | ||
return prom; | ||
@@ -445,3 +445,3 @@ } | ||
if(self.options.queue){ | ||
if (self.options.queue) { | ||
if (!self.queue[message.channel.id]) { | ||
@@ -457,22 +457,22 @@ self.queue[message.channel.id] = []; | ||
}); | ||
self.checkQueue(message.channel.id); | ||
}else{ | ||
} else { | ||
self._updateMessage(message, content).then(good).catch(bad); | ||
} | ||
function good(msg){ | ||
prom.message = msg; | ||
callback(null, msg); | ||
resolve(msg); | ||
} | ||
function bad(error){ | ||
prom.error = error; | ||
callback(error); | ||
reject(error); | ||
} | ||
function good(msg) { | ||
prom.message = msg; | ||
callback(null, msg); | ||
resolve(msg); | ||
} | ||
function bad(error) { | ||
prom.error = error; | ||
callback(error); | ||
reject(error); | ||
} | ||
}); | ||
return prom; | ||
@@ -625,3 +625,3 @@ } | ||
function send(destination) { | ||
if(self.options.queue){ | ||
if (self.options.queue) { | ||
//queue send file too | ||
@@ -634,4 +634,4 @@ if (!self.queue[destination]) { | ||
action: "sendFile", | ||
attachment : fstream, | ||
attachmentName : fileName, | ||
attachment: fstream, | ||
attachmentName: fileName, | ||
then: good, | ||
@@ -642,3 +642,3 @@ error: bad | ||
self.checkQueue(destination); | ||
}else{ | ||
} else { | ||
//not queue | ||
@@ -662,3 +662,3 @@ self._sendFile(destination, fstream, fileName).then(good).catch(bad); | ||
}); | ||
return prom; | ||
@@ -673,4 +673,4 @@ | ||
var prom = new Promise(function (resolve, reject) { | ||
if(typeof tts === "function"){ | ||
if (typeof tts === "function") { | ||
// tts is a function, which means the developer wants this to be the callback | ||
@@ -680,3 +680,3 @@ callback = tts; | ||
} | ||
message = premessage + resolveMessage(message); | ||
@@ -702,3 +702,3 @@ var mentions = resolveMentions(); | ||
mentions: mentions, | ||
tts : !!tts, //incase it's not a boolean | ||
tts: !!tts, //incase it's not a boolean | ||
then: mgood, | ||
@@ -744,3 +744,3 @@ error: mbad | ||
}); | ||
return prom; | ||
@@ -1201,3 +1201,3 @@ } | ||
mentions: mentions, | ||
tts : tts | ||
tts: tts | ||
}) | ||
@@ -1230,35 +1230,35 @@ .end(function (err, res) { | ||
} | ||
_sendFile(destination, attachment, attachmentName = "DEFAULT BECAUSE YOU DIDN'T SPECIFY WHY.png"){ | ||
_sendFile(destination, attachment, attachmentName = "DEFAULT BECAUSE YOU DIDN'T SPECIFY WHY.png") { | ||
var self = this; | ||
return new Promise(function(resolve, reject){ | ||
request | ||
.post(`${Endpoints.CHANNELS}/${destination}/messages`) | ||
.set("authorization", self.token) | ||
.attach("file", attachment, attachmentName) | ||
.end(function (err, res) { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
return new Promise(function (resolve, reject) { | ||
request | ||
.post(`${Endpoints.CHANNELS}/${destination}/messages`) | ||
.set("authorization", self.token) | ||
.attach("file", attachment, attachmentName) | ||
.end(function (err, res) { | ||
var chann = self.getChannel("id", destination); | ||
if (chann) { | ||
var msg = chann.addMessage(new Message(res.body, chann, [], self.user)); | ||
resolve(msg); | ||
} | ||
if (err) { | ||
reject(err); | ||
} else { | ||
var chann = self.getChannel("id", destination); | ||
if (chann) { | ||
var msg = chann.addMessage(new Message(res.body, chann, [], self.user)); | ||
resolve(msg); | ||
} | ||
}); | ||
} | ||
}); | ||
}); | ||
} | ||
_updateMessage(message, content){ | ||
_updateMessage(message, content) { | ||
var self = this; | ||
return new Promise(function(resolve, reject){ | ||
return new Promise(function (resolve, reject) { | ||
request | ||
@@ -1282,17 +1282,17 @@ .patch(`${Endpoints.CHANNELS}/${message.channel.id}/messages/${message.id}`) | ||
} | ||
_deleteMessage(message){ | ||
_deleteMessage(message) { | ||
var self = this; | ||
return new Promise(function(resolve, reject){ | ||
return new Promise(function (resolve, reject) { | ||
request | ||
.del(`${Endpoints.CHANNELS}/${message.channel.id}/messages/${message.id}`) | ||
.set("authorization", self.token) | ||
.end(function (err, res) { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(); | ||
} | ||
}); | ||
.del(`${Endpoints.CHANNELS}/${message.channel.id}/messages/${message.id}`) | ||
.set("authorization", self.token) | ||
.end(function (err, res) { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
@@ -1304,3 +1304,3 @@ } | ||
var self = this; | ||
if (!this.checkingQueue[channelID]) { | ||
@@ -1335,3 +1335,3 @@ //if we aren't already checking this queue. | ||
self._sendFile(channelID, fileToSend.attachment, fileToSend.attachmentName) | ||
.then(function (msg){ | ||
.then(function (msg) { | ||
fileToSend.then(msg); | ||
@@ -1341,3 +1341,3 @@ self.queue[channelID].shift(); | ||
}) | ||
.catch(function(err){ | ||
.catch(function (err) { | ||
fileToSend.error(err); | ||
@@ -1351,12 +1351,12 @@ self.queue[channelID].shift(); | ||
self._updateMessage(msgToUpd.message, msgToUpd.content) | ||
.then(function(msg){ | ||
msgToUpd.then(msg); | ||
self.queue[channelID].shift(); | ||
doNext(); | ||
}) | ||
.catch(function(err){ | ||
msgToUpd.error(err); | ||
self.queue[channelID].shift(); | ||
doNext(); | ||
}); | ||
.then(function (msg) { | ||
msgToUpd.then(msg); | ||
self.queue[channelID].shift(); | ||
doNext(); | ||
}) | ||
.catch(function (err) { | ||
msgToUpd.error(err); | ||
self.queue[channelID].shift(); | ||
doNext(); | ||
}); | ||
break; | ||
@@ -1366,12 +1366,12 @@ case "deleteMessage": | ||
self._deleteMessage(msgToDel.message) | ||
.then(function(msg){ | ||
msgToDel.then(msg); | ||
self.queue[channelID].shift(); | ||
doNext(); | ||
}) | ||
.catch(function(err){ | ||
msgToDel.error(err); | ||
self.queue[channelID].shift(); | ||
doNext(); | ||
}); | ||
.then(function (msg) { | ||
msgToDel.then(msg); | ||
self.queue[channelID].shift(); | ||
doNext(); | ||
}) | ||
.catch(function (err) { | ||
msgToDel.error(err); | ||
self.queue[channelID].shift(); | ||
doNext(); | ||
}); | ||
break; | ||
@@ -1390,22 +1390,20 @@ default: | ||
} | ||
} | ||
function getGateway() { | ||
var self = this; | ||
return new Promise(function (resolve, reject) { | ||
request | ||
.get(`${Endpoints.API}/gateway`) | ||
.end(function (err, res) { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(res.body.url); | ||
} | ||
}); | ||
}); | ||
getGateway() { | ||
var self = this; | ||
return new Promise(function (resolve, reject) { | ||
request | ||
.get(`${Endpoints.API}/gateway`) | ||
.set("authorization", self.token) | ||
.end(function (err, res) { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(res.body.url); | ||
} | ||
}); | ||
}); | ||
} | ||
} | ||
module.exports = Client; |
@@ -53,2 +53,6 @@ class Server { | ||
get users() { | ||
return this.members; | ||
} | ||
// get/set | ||
@@ -55,0 +59,0 @@ getChannel(key, value) { |
@@ -20,3 +20,3 @@ var Discord = require("../"); | ||
// we can go ahead :) | ||
mybot.sendMessage(message.author, message.sender.username); | ||
mybot.reply(message, message.channel); | ||
}); | ||
@@ -23,0 +23,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
536931
13635