mirror of
https://github.com/danbulant/discord.js
synced 2026-07-05 03:00:35 +00:00
Webpack build: 6383d42eb5
This commit is contained in:
parent
9afba6d555
commit
71626d413b
2 changed files with 115 additions and 59 deletions
168
discord.indev.js
168
discord.indev.js
|
|
@ -1410,7 +1410,7 @@
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/hydrabolt/discord.js#readme",
|
"homepage": "https://github.com/hydrabolt/discord.js#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"superagent": "^2.3.0",
|
"superagent": "^3.0.0",
|
||||||
"tweetnacl": "^0.14.3",
|
"tweetnacl": "^0.14.3",
|
||||||
"ws": "^1.1.1"
|
"ws": "^1.1.1"
|
||||||
},
|
},
|
||||||
|
|
@ -6675,7 +6675,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
var Emitter = __webpack_require__(41);
|
var Emitter = __webpack_require__(41);
|
||||||
var requestBase = __webpack_require__(42);
|
var RequestBase = __webpack_require__(42);
|
||||||
var isObject = __webpack_require__(43);
|
var isObject = __webpack_require__(43);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -7149,9 +7149,16 @@
|
||||||
err.parse = true;
|
err.parse = true;
|
||||||
err.original = e;
|
err.original = e;
|
||||||
// issue #675: return the raw response if the response parsing fails
|
// issue #675: return the raw response if the response parsing fails
|
||||||
err.rawResponse = self.xhr && self.xhr.responseText ? self.xhr.responseText : null;
|
if (self.xhr) {
|
||||||
// issue #876: return the http status code if the response parsing fails
|
// ie9 doesn't have 'response' property
|
||||||
err.statusCode = self.xhr && self.xhr.status ? self.xhr.status : null;
|
err.rawResponse = typeof self.xhr.responseType == 'undefined' ? self.xhr.responseText : self.xhr.response;
|
||||||
|
// issue #876: return the http status code if the response parsing fails
|
||||||
|
err.statusCode = self.xhr.status ? self.xhr.status : null;
|
||||||
|
} else {
|
||||||
|
err.rawResponse = null;
|
||||||
|
err.statusCode = null;
|
||||||
|
}
|
||||||
|
|
||||||
return self.callback(err);
|
return self.callback(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -7179,13 +7186,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mixin `Emitter` and `requestBase`.
|
* Mixin `Emitter` and `RequestBase`.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Emitter(Request.prototype);
|
Emitter(Request.prototype);
|
||||||
for (var key in requestBase) {
|
RequestBase(Request.prototype);
|
||||||
Request.prototype[key] = requestBase[key];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set Content-Type to `type`, mapping values from `request.types`.
|
* Set Content-Type to `type`, mapping values from `request.types`.
|
||||||
|
|
@ -7312,7 +7317,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queue the given `file` as an attachment to the specified `field`,
|
* Queue the given `file` as an attachment to the specified `field`,
|
||||||
* with optional `filename`.
|
* with optional `options` (or filename).
|
||||||
*
|
*
|
||||||
* ``` js
|
* ``` js
|
||||||
* request.post('/upload')
|
* request.post('/upload')
|
||||||
|
|
@ -7322,13 +7327,17 @@
|
||||||
*
|
*
|
||||||
* @param {String} field
|
* @param {String} field
|
||||||
* @param {Blob|File} file
|
* @param {Blob|File} file
|
||||||
* @param {String} filename
|
* @param {String|Object} options
|
||||||
* @return {Request} for chaining
|
* @return {Request} for chaining
|
||||||
* @api public
|
* @api public
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Request.prototype.attach = function(field, file, filename){
|
Request.prototype.attach = function(field, file, options){
|
||||||
this._getFormData().append(field, file, filename || file.name);
|
if (this._data) {
|
||||||
|
throw Error("superagent can't mix .send() and .attach()");
|
||||||
|
}
|
||||||
|
|
||||||
|
this._getFormData().append(field, file, options || file.name);
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -7351,6 +7360,11 @@
|
||||||
Request.prototype.callback = function(err, res){
|
Request.prototype.callback = function(err, res){
|
||||||
var fn = this._callback;
|
var fn = this._callback;
|
||||||
this.clearTimeout();
|
this.clearTimeout();
|
||||||
|
|
||||||
|
if (err) {
|
||||||
|
this.emit('error', err);
|
||||||
|
}
|
||||||
|
|
||||||
fn(err, res);
|
fn(err, res);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -7371,6 +7385,17 @@
|
||||||
this.callback(err);
|
this.callback(err);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// This only warns, because the request is still likely to work
|
||||||
|
Request.prototype.buffer = Request.prototype.ca = Request.prototype.agent = function(){
|
||||||
|
console.warn("This is not supported in browser version of superagent");
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
|
// This throws, because it can't send/receive data as expected
|
||||||
|
Request.prototype.pipe = Request.prototype.write = function(){
|
||||||
|
throw Error("Streaming is not supported in browser version of superagent");
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Invoke callback with timeout error.
|
* Invoke callback with timeout error.
|
||||||
*
|
*
|
||||||
|
|
@ -7399,6 +7424,19 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if `obj` is a host object,
|
||||||
|
* we don't want to serialize these :)
|
||||||
|
*
|
||||||
|
* @param {Object} obj
|
||||||
|
* @return {Boolean}
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
Request.prototype._isHost = function _isHost(obj) {
|
||||||
|
// Native objects stringify to [object File], [object Blob], [object FormData], etc.
|
||||||
|
return obj && 'object' === typeof obj && !Array.isArray(obj) && Object.prototype.toString.call(obj) !== '[object Object]';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initiate request, invoking callback `fn(res)`
|
* Initiate request, invoking callback `fn(res)`
|
||||||
* with an instanceof `Response`.
|
* with an instanceof `Response`.
|
||||||
|
|
@ -7816,6 +7854,37 @@
|
||||||
*/
|
*/
|
||||||
var isObject = __webpack_require__(43);
|
var isObject = __webpack_require__(43);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expose `RequestBase`.
|
||||||
|
*/
|
||||||
|
|
||||||
|
module.exports = RequestBase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize a new `RequestBase`.
|
||||||
|
*
|
||||||
|
* @api public
|
||||||
|
*/
|
||||||
|
|
||||||
|
function RequestBase(obj) {
|
||||||
|
if (obj) return mixin(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mixin the prototype properties.
|
||||||
|
*
|
||||||
|
* @param {Object} obj
|
||||||
|
* @return {Object}
|
||||||
|
* @api private
|
||||||
|
*/
|
||||||
|
|
||||||
|
function mixin(obj) {
|
||||||
|
for (var key in RequestBase.prototype) {
|
||||||
|
obj[key] = RequestBase.prototype[key];
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear previous timeout.
|
* Clear previous timeout.
|
||||||
*
|
*
|
||||||
|
|
@ -7823,7 +7892,7 @@
|
||||||
* @api public
|
* @api public
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exports.clearTimeout = function _clearTimeout(){
|
RequestBase.prototype.clearTimeout = function _clearTimeout(){
|
||||||
this._timeout = 0;
|
this._timeout = 0;
|
||||||
clearTimeout(this._timer);
|
clearTimeout(this._timer);
|
||||||
return this;
|
return this;
|
||||||
|
|
@ -7838,7 +7907,7 @@
|
||||||
* @api public
|
* @api public
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exports.parse = function parse(fn){
|
RequestBase.prototype.parse = function parse(fn){
|
||||||
this._parser = fn;
|
this._parser = fn;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
@ -7852,7 +7921,7 @@
|
||||||
* @api public
|
* @api public
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exports.serialize = function serialize(fn){
|
RequestBase.prototype.serialize = function serialize(fn){
|
||||||
this._serializer = fn;
|
this._serializer = fn;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
@ -7865,7 +7934,7 @@
|
||||||
* @api public
|
* @api public
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exports.timeout = function timeout(ms){
|
RequestBase.prototype.timeout = function timeout(ms){
|
||||||
this._timeout = ms;
|
this._timeout = ms;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
@ -7878,7 +7947,7 @@
|
||||||
* @return {Request}
|
* @return {Request}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exports.then = function then(resolve, reject) {
|
RequestBase.prototype.then = function then(resolve, reject) {
|
||||||
if (!this._fullfilledPromise) {
|
if (!this._fullfilledPromise) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this._fullfilledPromise = new Promise(function(innerResolve, innerReject){
|
this._fullfilledPromise = new Promise(function(innerResolve, innerReject){
|
||||||
|
|
@ -7890,7 +7959,7 @@
|
||||||
return this._fullfilledPromise.then(resolve, reject);
|
return this._fullfilledPromise.then(resolve, reject);
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.catch = function(cb) {
|
RequestBase.prototype.catch = function(cb) {
|
||||||
return this.then(undefined, cb);
|
return this.then(undefined, cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -7898,7 +7967,7 @@
|
||||||
* Allow for extension
|
* Allow for extension
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exports.use = function use(fn) {
|
RequestBase.prototype.use = function use(fn) {
|
||||||
fn(this);
|
fn(this);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
@ -7913,7 +7982,7 @@
|
||||||
* @api public
|
* @api public
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exports.get = function(field){
|
RequestBase.prototype.get = function(field){
|
||||||
return this._header[field.toLowerCase()];
|
return this._header[field.toLowerCase()];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -7929,7 +7998,7 @@
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exports.getHeader = exports.get;
|
RequestBase.prototype.getHeader = RequestBase.prototype.get;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set header `field` to `val`, or multiple fields with one object.
|
* Set header `field` to `val`, or multiple fields with one object.
|
||||||
|
|
@ -7952,7 +8021,7 @@
|
||||||
* @api public
|
* @api public
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exports.set = function(field, val){
|
RequestBase.prototype.set = function(field, val){
|
||||||
if (isObject(field)) {
|
if (isObject(field)) {
|
||||||
for (var key in field) {
|
for (var key in field) {
|
||||||
this.set(key, field[key]);
|
this.set(key, field[key]);
|
||||||
|
|
@ -7976,7 +8045,7 @@
|
||||||
*
|
*
|
||||||
* @param {String} field
|
* @param {String} field
|
||||||
*/
|
*/
|
||||||
exports.unset = function(field){
|
RequestBase.prototype.unset = function(field){
|
||||||
delete this._header[field.toLowerCase()];
|
delete this._header[field.toLowerCase()];
|
||||||
delete this.header[field];
|
delete this.header[field];
|
||||||
return this;
|
return this;
|
||||||
|
|
@ -8001,7 +8070,7 @@
|
||||||
* @return {Request} for chaining
|
* @return {Request} for chaining
|
||||||
* @api public
|
* @api public
|
||||||
*/
|
*/
|
||||||
exports.field = function(name, val) {
|
RequestBase.prototype.field = function(name, val) {
|
||||||
|
|
||||||
// name should be either a string or an object.
|
// name should be either a string or an object.
|
||||||
if (null === name || undefined === name) {
|
if (null === name || undefined === name) {
|
||||||
|
|
@ -8029,7 +8098,7 @@
|
||||||
* @return {Request}
|
* @return {Request}
|
||||||
* @api public
|
* @api public
|
||||||
*/
|
*/
|
||||||
exports.abort = function(){
|
RequestBase.prototype.abort = function(){
|
||||||
if (this._aborted) {
|
if (this._aborted) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
@ -8052,7 +8121,7 @@
|
||||||
* @api public
|
* @api public
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exports.withCredentials = function(){
|
RequestBase.prototype.withCredentials = function(){
|
||||||
// This is browser-only functionality. Node side is no-op.
|
// This is browser-only functionality. Node side is no-op.
|
||||||
this._withCredentials = true;
|
this._withCredentials = true;
|
||||||
return this;
|
return this;
|
||||||
|
|
@ -8066,7 +8135,7 @@
|
||||||
* @api public
|
* @api public
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exports.redirects = function(n){
|
RequestBase.prototype.redirects = function(n){
|
||||||
this._maxRedirects = n;
|
this._maxRedirects = n;
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
@ -8080,7 +8149,7 @@
|
||||||
* @api public
|
* @api public
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exports.toJSON = function(){
|
RequestBase.prototype.toJSON = function(){
|
||||||
return {
|
return {
|
||||||
method: this.method,
|
method: this.method,
|
||||||
url: this.url,
|
url: this.url,
|
||||||
|
|
@ -8089,29 +8158,6 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if `obj` is a host object,
|
|
||||||
* we don't want to serialize these :)
|
|
||||||
*
|
|
||||||
* TODO: future proof, move to compoent land
|
|
||||||
*
|
|
||||||
* @param {Object} obj
|
|
||||||
* @return {Boolean}
|
|
||||||
* @api private
|
|
||||||
*/
|
|
||||||
|
|
||||||
exports._isHost = function _isHost(obj) {
|
|
||||||
var str = {}.toString.call(obj);
|
|
||||||
|
|
||||||
switch (str) {
|
|
||||||
case '[object File]':
|
|
||||||
case '[object Blob]':
|
|
||||||
case '[object FormData]':
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send `data` as the request body, defaulting the `.type()` to "json" when
|
* Send `data` as the request body, defaulting the `.type()` to "json" when
|
||||||
|
|
@ -8153,12 +8199,22 @@
|
||||||
* @api public
|
* @api public
|
||||||
*/
|
*/
|
||||||
|
|
||||||
exports.send = function(data){
|
RequestBase.prototype.send = function(data){
|
||||||
var obj = isObject(data);
|
var isObj = isObject(data);
|
||||||
var type = this._header['content-type'];
|
var type = this._header['content-type'];
|
||||||
|
|
||||||
|
if (isObj && !this._data) {
|
||||||
|
if (Array.isArray(data)) {
|
||||||
|
this._data = [];
|
||||||
|
} else if (!this._isHost(data)) {
|
||||||
|
this._data = {};
|
||||||
|
}
|
||||||
|
} else if (data && this._data && this._isHost(this._data)) {
|
||||||
|
throw Error("Can't merge these send calls");
|
||||||
|
}
|
||||||
|
|
||||||
// merge
|
// merge
|
||||||
if (obj && isObject(this._data)) {
|
if (isObj && isObject(this._data)) {
|
||||||
for (var key in data) {
|
for (var key in data) {
|
||||||
this._data[key] = data[key];
|
this._data[key] = data[key];
|
||||||
}
|
}
|
||||||
|
|
@ -8177,7 +8233,7 @@
|
||||||
this._data = data;
|
this._data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!obj || this._isHost(data)) return this;
|
if (!isObj || this._isHost(data)) return this;
|
||||||
|
|
||||||
// default to json
|
// default to json
|
||||||
if (!type) this.type('json');
|
if (!type) this.type('json');
|
||||||
|
|
|
||||||
6
discord.indev.min.js
vendored
6
discord.indev.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue