mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
sendFile and fix deleteMessage
This commit is contained in:
@@ -251,6 +251,33 @@ var InternalClient = (function () {
|
||||
});
|
||||
};
|
||||
|
||||
InternalClient.prototype.sendFile = function sendFile(where, _file) {
|
||||
var name = arguments.length <= 2 || arguments[2] === undefined ? "image.png" : arguments[2];
|
||||
|
||||
var self = this;
|
||||
return new Promise(function (resolve, reject) {
|
||||
self.resolver.resolveChannel(where).then(next)["catch"](function (e) {
|
||||
return reject(new Error("couldn't resolve to channel - " + e));
|
||||
});
|
||||
|
||||
function next(channel) {
|
||||
|
||||
var file = self.resolver.resolveFile(_file);
|
||||
|
||||
request.post(Endpoints.CHANNEL_MESSAGES(channel.id)).set("authorization", self.token).attach("file", file, name).end(function (err, res) {
|
||||
|
||||
if (err) {
|
||||
reject(new Error(err.response.text));
|
||||
} else {
|
||||
resolve(channel.messages.add(new Message(res.body, channel, self.client)));
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// def getChannelLogs
|
||||
|
||||
InternalClient.prototype.getChannelLogs = function getChannelLogs(_channel) {
|
||||
var limit = arguments.length <= 1 || arguments[1] === undefined ? 500 : arguments[1];
|
||||
var options = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
|
||||
|
||||
Reference in New Issue
Block a user