mirror of
https://github.com/danbulant/discord.js
synced 2026-06-18 14:11:09 +00:00
Webpack build for branch voice-rewrite: ac7e066126
This commit is contained in:
parent
8aac85ba7e
commit
deb03b26c6
2 changed files with 208 additions and 66 deletions
|
|
@ -180,7 +180,7 @@ function makeImageUrl(root, { format = 'webp', size } = {}) {
|
|||
exports.Endpoints = {
|
||||
CDN(root) {
|
||||
return {
|
||||
Emoji: emojiID => `${root}/emojis/${emojiID}.png`,
|
||||
Emoji: (emojiID, format = 'png') => `${root}/emojis/${emojiID}.${format}`,
|
||||
Asset: name => `${root}/assets/${name}`,
|
||||
DefaultAvatar: number => `${root}/embed/avatars/${number}.png`,
|
||||
Avatar: (userID, hash, format = 'default', size) => {
|
||||
|
|
@ -1348,18 +1348,21 @@ class Util {
|
|||
* Parses emoji info out of a string. The string must be one of:
|
||||
* * A UTF-8 emoji (no ID)
|
||||
* * A URL-encoded UTF-8 emoji (no ID)
|
||||
* * A Discord custom emoji (`<:name:id>`)
|
||||
* * A Discord custom emoji (`<:name:id>` or `<a:name:id>`)
|
||||
* @param {string} text Emoji string to parse
|
||||
* @returns {Object} Object with `name` and `id` properties
|
||||
* @returns {Object} Object with `animated`, `name`, and `id` properties
|
||||
* @private
|
||||
*/
|
||||
static parseEmoji(text) {
|
||||
if (text.includes('%')) text = decodeURIComponent(text);
|
||||
if (text.includes(':')) {
|
||||
const [name, id] = text.split(':');
|
||||
return { name, id };
|
||||
const m = text.match(/<?(a)?:(\w{2,32}):(\d{17,19})>?/);
|
||||
if (!m) {
|
||||
return null;
|
||||
}
|
||||
return { animated: Boolean(m[1]), name: m[2], id: m[3] };
|
||||
} else {
|
||||
return { name: text, id: null };
|
||||
return { animated: false, name: text, id: null };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3383,7 +3386,7 @@ const { MessageNotificationTypes } = __webpack_require__(0);
|
|||
const { Error, TypeError } = __webpack_require__(4);
|
||||
|
||||
/**
|
||||
* Represents a guild channel (e.g. text channels and voice channels).
|
||||
* Represents a guild channel (i.g. a {@link TextChannel}, {@link VoiceChannel} or {@link CategoryChannel}).
|
||||
* @extends {Channel}
|
||||
*/
|
||||
class GuildChannel extends Channel {
|
||||
|
|
@ -3697,14 +3700,15 @@ class GuildChannel extends Channel {
|
|||
|
||||
/**
|
||||
* Sets the category parent of this channel.
|
||||
* @param {GuildChannel|Snowflake} channel Parent channel
|
||||
* @param {boolean} [options.lockPermissions] Lock the permissions to what the parent's permissions are
|
||||
* @param {?GuildChannel|Snowflake} channel Parent channel
|
||||
* @param {Object} [options={}] Options to pass
|
||||
* @param {boolean} [options.lockPermissions=true] Lock the permissions to what the parent's permissions are
|
||||
* @param {string} [options.reason] Reason for modifying the parent of this channel
|
||||
* @returns {Promise<GuildChannel>}
|
||||
*/
|
||||
setParent(channel, { lockPermissions = true, reason } = {}) {
|
||||
return this.edit({
|
||||
parentID: channel.id ? channel.id : channel,
|
||||
parentID: channel !== null ? channel.id ? channel.id : channel : null,
|
||||
lockPermissions,
|
||||
}, reason);
|
||||
}
|
||||
|
|
@ -5397,8 +5401,8 @@ class Guild extends Base {
|
|||
/**
|
||||
* Creates a new channel in the guild.
|
||||
* @param {string} name The name of the new channel
|
||||
* @param {string} type The type of the new channel, either `text`, `voice`, or `category`
|
||||
* @param {Object} [options] Options
|
||||
* @param {string} [options.type='text'] The type of the new channel, either `text`, `voice`, or `category`
|
||||
* @param {boolean} [options.nsfw] Whether the new channel is nsfw
|
||||
* @param {number} [options.bitrate] Bitrate of the new channel in bits (only voice)
|
||||
* @param {number} [options.userLimit] Maximum amount of users allowed in the new channel (only voice)
|
||||
|
|
@ -5412,7 +5416,7 @@ class Guild extends Base {
|
|||
* .then(channel => console.log(`Created new channel ${channel}`))
|
||||
* .catch(console.error);
|
||||
*/
|
||||
createChannel(name, type, { nsfw, bitrate, userLimit, parent, overwrites, reason } = {}) {
|
||||
createChannel(name, { type, nsfw, bitrate, userLimit, parent, overwrites, reason } = {}) {
|
||||
if (overwrites instanceof Collection || overwrites instanceof Array) {
|
||||
overwrites = overwrites.map(overwrite => {
|
||||
let allow = overwrite.allow || (overwrite.allowed ? overwrite.allowed.bitfield : 0);
|
||||
|
|
@ -5442,7 +5446,7 @@ class Guild extends Base {
|
|||
return this.client.api.guilds(this.id).channels.post({
|
||||
data: {
|
||||
name,
|
||||
type: ChannelTypes[type.toUpperCase()],
|
||||
type: type ? ChannelTypes[type.toUpperCase()] : 'text',
|
||||
nsfw,
|
||||
bitrate,
|
||||
user_limit: userLimit,
|
||||
|
|
@ -6639,6 +6643,12 @@ class Emoji extends Base {
|
|||
*/
|
||||
this.managed = data.managed;
|
||||
|
||||
/**
|
||||
* Whether this emoji is animated
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.animated = data.animated;
|
||||
|
||||
this._roles = data.roles;
|
||||
}
|
||||
|
||||
|
|
@ -6679,7 +6689,7 @@ class Emoji extends Base {
|
|||
* @readonly
|
||||
*/
|
||||
get url() {
|
||||
return this.client.rest.cdn.Emoji(this.id);
|
||||
return this.client.rest.cdn.Emoji(this.id, this.animated ? 'gif' : 'png');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -6792,7 +6802,11 @@ class Emoji extends Base {
|
|||
* msg.reply(`Hello! ${emoji}`);
|
||||
*/
|
||||
toString() {
|
||||
return this.requiresColons ? `<:${this.name}:${this.id}>` : this.name;
|
||||
if (!this.id || !this.requiresColons) {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
return `<${this.animated ? 'a' : ''}:${this.name}:${this.id}>`;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -7848,10 +7862,10 @@ class Message extends Base {
|
|||
}
|
||||
if (!options.content) options.content = content;
|
||||
|
||||
const { data, files } = await createMessage(this, options);
|
||||
const { data } = await createMessage(this, options);
|
||||
|
||||
return this.client.api.channels[this.channel.id].messages[this.id]
|
||||
.patch({ data, files })
|
||||
.patch({ data })
|
||||
.then(d => {
|
||||
const clone = this._clone();
|
||||
clone._patch(d);
|
||||
|
|
@ -8030,29 +8044,66 @@ module.exports = Message;
|
|||
|
||||
"use strict";
|
||||
Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "delete", function() { return delete_; });
|
||||
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "delete", function() { return _delete; });
|
||||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__index_js__ = __webpack_require__(78);
|
||||
/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__index_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__index_js__);
|
||||
|
||||
|
||||
/* harmony default export */ __webpack_exports__["default"] = (__WEBPACK_IMPORTED_MODULE_0__index_js___default.a);
|
||||
|
||||
const version = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.version;
|
||||
/* harmony export (immutable) */ __webpack_exports__["version"] = version;
|
||||
|
||||
const METHODS = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.METHODS;
|
||||
/* harmony export (immutable) */ __webpack_exports__["METHODS"] = METHODS;
|
||||
|
||||
|
||||
const acl = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.acl;
|
||||
/* harmony export (immutable) */ __webpack_exports__["acl"] = acl;
|
||||
|
||||
const bind = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.bind;
|
||||
/* harmony export (immutable) */ __webpack_exports__["bind"] = bind;
|
||||
|
||||
const checkout = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.checkout;
|
||||
/* harmony export (immutable) */ __webpack_exports__["checkout"] = checkout;
|
||||
|
||||
const connect = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.connect;
|
||||
/* harmony export (immutable) */ __webpack_exports__["connect"] = connect;
|
||||
|
||||
const copy = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.copy;
|
||||
/* harmony export (immutable) */ __webpack_exports__["copy"] = copy;
|
||||
|
||||
const _delete = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.delete;
|
||||
|
||||
const get = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.get;
|
||||
/* harmony export (immutable) */ __webpack_exports__["get"] = get;
|
||||
|
||||
const head = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.head;
|
||||
/* harmony export (immutable) */ __webpack_exports__["head"] = head;
|
||||
|
||||
const post = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.post;
|
||||
/* harmony export (immutable) */ __webpack_exports__["post"] = post;
|
||||
const link = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.link;
|
||||
/* harmony export (immutable) */ __webpack_exports__["link"] = link;
|
||||
|
||||
const put = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.put;
|
||||
/* harmony export (immutable) */ __webpack_exports__["put"] = put;
|
||||
const lock = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.lock;
|
||||
/* harmony export (immutable) */ __webpack_exports__["lock"] = lock;
|
||||
|
||||
const delete_ = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.delete;
|
||||
const merge = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.merge;
|
||||
/* harmony export (immutable) */ __webpack_exports__["merge"] = merge;
|
||||
|
||||
const connect = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.connect;
|
||||
/* harmony export (immutable) */ __webpack_exports__["connect"] = connect;
|
||||
const mkactivity = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.mkactivity;
|
||||
/* harmony export (immutable) */ __webpack_exports__["mkactivity"] = mkactivity;
|
||||
|
||||
const mkcalendar = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.mkcalendar;
|
||||
/* harmony export (immutable) */ __webpack_exports__["mkcalendar"] = mkcalendar;
|
||||
|
||||
const mkcol = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.mkcol;
|
||||
/* harmony export (immutable) */ __webpack_exports__["mkcol"] = mkcol;
|
||||
|
||||
const move = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.move;
|
||||
/* harmony export (immutable) */ __webpack_exports__["move"] = move;
|
||||
|
||||
const notify = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.notify;
|
||||
/* harmony export (immutable) */ __webpack_exports__["notify"] = notify;
|
||||
|
||||
const options = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.options;
|
||||
/* harmony export (immutable) */ __webpack_exports__["options"] = options;
|
||||
|
|
@ -8060,6 +8111,51 @@ const options = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.options;
|
|||
const patch = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.patch;
|
||||
/* harmony export (immutable) */ __webpack_exports__["patch"] = patch;
|
||||
|
||||
const post = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.post;
|
||||
/* harmony export (immutable) */ __webpack_exports__["post"] = post;
|
||||
|
||||
const propfind = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.propfind;
|
||||
/* harmony export (immutable) */ __webpack_exports__["propfind"] = propfind;
|
||||
|
||||
const proppatch = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.proppatch;
|
||||
/* harmony export (immutable) */ __webpack_exports__["proppatch"] = proppatch;
|
||||
|
||||
const purge = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.purge;
|
||||
/* harmony export (immutable) */ __webpack_exports__["purge"] = purge;
|
||||
|
||||
const put = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.put;
|
||||
/* harmony export (immutable) */ __webpack_exports__["put"] = put;
|
||||
|
||||
const rebind = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.rebind;
|
||||
/* harmony export (immutable) */ __webpack_exports__["rebind"] = rebind;
|
||||
|
||||
const report = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.report;
|
||||
/* harmony export (immutable) */ __webpack_exports__["report"] = report;
|
||||
|
||||
const search = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.search;
|
||||
/* harmony export (immutable) */ __webpack_exports__["search"] = search;
|
||||
|
||||
const subscribe = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.subscribe;
|
||||
/* harmony export (immutable) */ __webpack_exports__["subscribe"] = subscribe;
|
||||
|
||||
const trace = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.trace;
|
||||
/* harmony export (immutable) */ __webpack_exports__["trace"] = trace;
|
||||
|
||||
const unbind = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.unbind;
|
||||
/* harmony export (immutable) */ __webpack_exports__["unbind"] = unbind;
|
||||
|
||||
const unlink = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.unlink;
|
||||
/* harmony export (immutable) */ __webpack_exports__["unlink"] = unlink;
|
||||
|
||||
const unlock = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.unlock;
|
||||
/* harmony export (immutable) */ __webpack_exports__["unlock"] = unlock;
|
||||
|
||||
const unsubscribe = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.unsubscribe;
|
||||
/* harmony export (immutable) */ __webpack_exports__["unsubscribe"] = unsubscribe;
|
||||
|
||||
const brew = __WEBPACK_IMPORTED_MODULE_0__index_js___default.a.brew;
|
||||
/* harmony export (immutable) */ __webpack_exports__["brew"] = brew;
|
||||
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
|
@ -8271,17 +8367,18 @@ class Collector extends EventEmitter {
|
|||
*/
|
||||
handleCollect(...args) {
|
||||
const collect = this.collect(...args);
|
||||
if (!collect || !this.filter(...args, this.collected)) return;
|
||||
|
||||
this.collected.set(collect.key, collect.value);
|
||||
if (collect && this.filter(...args, this.collected)) {
|
||||
this.collected.set(collect.key, collect.value);
|
||||
|
||||
/**
|
||||
* Emitted whenever an element is collected.
|
||||
* @event Collector#collect
|
||||
* @param {*} element The element that got collected
|
||||
* @param {...*} args The arguments emitted by the listener
|
||||
*/
|
||||
this.emit('collect', collect.value, ...args);
|
||||
/**
|
||||
* Emitted whenever an element is collected.
|
||||
* @event Collector#collect
|
||||
* @param {*} element The element that got collected
|
||||
* @param {...*} args The arguments emitted by the listener
|
||||
*/
|
||||
this.emit('collect', collect.value, ...args);
|
||||
}
|
||||
this.checkEnd();
|
||||
}
|
||||
|
||||
|
|
@ -10449,18 +10546,31 @@ module.exports = async function createMessage(channel, options) {
|
|||
if (isNaN(options.nonce) || options.nonce < 0) throw new RangeError('MESSAGE_NONCE_TYPE');
|
||||
}
|
||||
|
||||
let { content } = options;
|
||||
if (options instanceof MessageEmbed) options = webhook ? { embeds: [options] } : { embed: options };
|
||||
if (options instanceof MessageAttachment) options = { files: [options.file] };
|
||||
|
||||
if (content instanceof Array || options instanceof Array) {
|
||||
const which = content instanceof Array ? content : options;
|
||||
const attachments = which.filter(item => item instanceof MessageAttachment);
|
||||
const embeds = which.filter(item => item instanceof MessageEmbed);
|
||||
if (attachments.length) options = { files: attachments };
|
||||
if (embeds.length) options = { embeds };
|
||||
if ((embeds.length || attachments.length) && content instanceof Array) {
|
||||
content = null;
|
||||
options.content = '';
|
||||
}
|
||||
}
|
||||
|
||||
if (options.reply && !(channel instanceof User || channel instanceof GuildMember) && channel.type !== 'dm') {
|
||||
const id = channel.client.users.resolveID(options.reply);
|
||||
const mention = `<@${options.reply instanceof GuildMember && options.reply.nickname ? '!' : ''}${id}>`;
|
||||
if (options.split) options.split.prepend = `${mention}, ${options.split.prepend || ''}`;
|
||||
options.content = `${mention}${typeof options.content !== 'undefined' ? `, ${options.content}` : ''}`;
|
||||
content = `${mention}${typeof options.content !== 'undefined' ? `, ${options.content}` : ''}`;
|
||||
}
|
||||
|
||||
if (options.content) {
|
||||
options.content = Util.resolveString(options.content);
|
||||
if (content) {
|
||||
options.content = Util.resolveString(content);
|
||||
if (options.split && typeof options.split !== 'object') options.split = {};
|
||||
// Wrap everything in a code block
|
||||
if (typeof options.code !== 'undefined' && (typeof options.code !== 'boolean' || options.code === true)) {
|
||||
|
|
@ -11479,6 +11589,19 @@ class CategoryChannel extends GuildChannel {
|
|||
get children() {
|
||||
return this.guild.channels.filter(c => c.parentID === this.id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the category parent of this channel.
|
||||
* <warn>It is not currently possible to set the parent of a CategoryChannel.</warn>
|
||||
* @method setParent
|
||||
* @memberof CategoryChannel
|
||||
* @instance
|
||||
* @param {?GuildChannel|Snowflake} channel Parent channel
|
||||
* @param {Object} [options={}] Options to pass
|
||||
* @param {boolean} [options.lockPermissions=true] Lock the permissions to what the parent's permissions are
|
||||
* @param {string} [options.reason] Reason for modifying the parent of this channel
|
||||
* @returns {Promise<GuildChannel>}
|
||||
*/
|
||||
}
|
||||
|
||||
module.exports = CategoryChannel;
|
||||
|
|
@ -12526,7 +12649,7 @@ const transport = browser ? __webpack_require__(83) : __webpack_require__(84);
|
|||
class Snekfetch extends transport.Extension {
|
||||
/**
|
||||
* Options to pass to the Snekfetch constructor
|
||||
* @typedef {object} snekfetchOptions
|
||||
* @typedef {object} SnekfetchOptions
|
||||
* @memberof Snekfetch
|
||||
* @property {object} [headers] Headers to initialize the request with
|
||||
* @property {object|string|Buffer} [data] Data to initialize the request with
|
||||
|
|
@ -12544,14 +12667,16 @@ class Snekfetch extends transport.Extension {
|
|||
* `new Snekfetch(method, url [, options])`
|
||||
* @param {string} method HTTP method
|
||||
* @param {string} url URL
|
||||
* @param {Snekfetch.snekfetchOptions} opts Options
|
||||
* @param {SnekfetchOptions} [opts] Options
|
||||
*/
|
||||
constructor(method, url, opts = {}) {
|
||||
super();
|
||||
this.options = Object.assign({ version: 1, qs: querystring, followRedirects: true }, opts);
|
||||
this.request = transport.buildRequest.call(this, method, url, opts);
|
||||
if (opts.query) this.query(opts.query);
|
||||
if (opts.data) this.send(opts.data);
|
||||
if (opts.query)
|
||||
this.query(opts.query);
|
||||
if (opts.data)
|
||||
this.send(opts.data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -12562,12 +12687,15 @@ class Snekfetch extends transport.Extension {
|
|||
*/
|
||||
query(name, value) {
|
||||
this._checkModify();
|
||||
if (!this.request.query) this.request.query = {};
|
||||
if (!this.request.query)
|
||||
this.request.query = {};
|
||||
if (name !== null && typeof name === 'object') {
|
||||
for (const [k, v] of Object.entries(name)) this.query(k, v);
|
||||
for (const [k, v] of Object.entries(name))
|
||||
this.query(k, v);
|
||||
} else {
|
||||
this.request.query[name] = value;
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -12580,10 +12708,12 @@ class Snekfetch extends transport.Extension {
|
|||
set(name, value) {
|
||||
this._checkModify();
|
||||
if (name !== null && typeof name === 'object') {
|
||||
for (const key of Object.keys(name)) this.set(key, name[key]);
|
||||
for (const key of Object.keys(name))
|
||||
this.set(key, name[key]);
|
||||
} else {
|
||||
this.request.setHeader(name, value);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -12598,10 +12728,12 @@ class Snekfetch extends transport.Extension {
|
|||
this._checkModify();
|
||||
const form = this._getFormData();
|
||||
if (typeof args[0] === 'object') {
|
||||
for (const [k, v] of Object.entries(args[0])) this.attach(k, v);
|
||||
for (const [k, v] of Object.entries(args[0]))
|
||||
this.attach(k, v);
|
||||
} else {
|
||||
form.append(...args);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -12618,8 +12750,10 @@ class Snekfetch extends transport.Extension {
|
|||
const header = this.request.getHeader('content-type');
|
||||
let serialize;
|
||||
if (header) {
|
||||
if (header.includes('json')) serialize = JSON.stringify;
|
||||
else if (header.includes('urlencoded')) serialize = this.options.qs.stringify;
|
||||
if (header.includes('json'))
|
||||
serialize = JSON.stringify;
|
||||
else if (header.includes('urlencoded'))
|
||||
serialize = this.options.qs.stringify;
|
||||
} else {
|
||||
this.set('Content-Type', 'application/json');
|
||||
serialize = JSON.stringify;
|
||||
|
|
@ -12632,14 +12766,16 @@ class Snekfetch extends transport.Extension {
|
|||
}
|
||||
|
||||
then(resolver, rejector) {
|
||||
if (this._response) return this._response.then(resolver, rejector);
|
||||
if (this._response)
|
||||
return this._response.then(resolver, rejector);
|
||||
// eslint-disable-next-line no-return-assign
|
||||
return this._response = transport.finalizeRequest.call(this)
|
||||
.then(({ response, raw, redirect, headers }) => {
|
||||
if (redirect) {
|
||||
let method = this.request.method;
|
||||
if ([301, 302].includes(response.statusCode)) {
|
||||
if (method !== 'HEAD') method = 'GET';
|
||||
if (method !== 'HEAD')
|
||||
method = 'GET';
|
||||
this.data = null;
|
||||
} else if (response.statusCode === 303) {
|
||||
method = 'GET';
|
||||
|
|
@ -12650,6 +12786,7 @@ class Snekfetch extends transport.Extension {
|
|||
return new Snekfetch(method, redirect, {
|
||||
data: this.data,
|
||||
headers: redirectHeaders,
|
||||
version: this.options.version,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -12721,21 +12858,23 @@ class Snekfetch extends transport.Extension {
|
|||
}
|
||||
|
||||
_getFormData() {
|
||||
if (!(this.data instanceof transport.FormData)) {
|
||||
if (!(this.data instanceof transport.FormData))
|
||||
this.data = new transport.FormData();
|
||||
}
|
||||
|
||||
return this.data;
|
||||
}
|
||||
|
||||
_finalizeRequest() {
|
||||
if (!this.request) return;
|
||||
if (!this.request.getHeader('user-agent')) {
|
||||
if (!this.request)
|
||||
return;
|
||||
if (!this.request.getHeader('user-agent'))
|
||||
this.set('User-Agent', `snekfetch/${Snekfetch.version} (${Package.homepage})`);
|
||||
}
|
||||
if (this.request.method !== 'HEAD') this.set('Accept-Encoding', 'gzip, deflate');
|
||||
if (this.data && this.data.getBoundary) {
|
||||
|
||||
if (this.request.method !== 'HEAD')
|
||||
this.set('Accept-Encoding', 'gzip, deflate');
|
||||
if (this.data && this.data.getBoundary)
|
||||
this.set('Content-Type', `multipart/form-data; boundary=${this.data.getBoundary()}`);
|
||||
}
|
||||
|
||||
if (this.request.query) {
|
||||
const [path, query] = this.request.path.split('?');
|
||||
this.request.path = `${path}?${this.options.qs.stringify(this.request.query)}${query ? `&${query}` : ''}`;
|
||||
|
|
@ -12743,7 +12882,8 @@ class Snekfetch extends transport.Extension {
|
|||
}
|
||||
|
||||
_checkModify() {
|
||||
if (this.response) throw new Error('Cannot modify request after it has been sent!');
|
||||
if (this.response)
|
||||
throw new Error('Cannot modify request after it has been sent!');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -12759,7 +12899,10 @@ Snekfetch.version = Package.version;
|
|||
*/
|
||||
Snekfetch.METHODS = transport.METHODS.concat('BREW').filter((m) => m !== 'M-SEARCH');
|
||||
for (const method of Snekfetch.METHODS) {
|
||||
Snekfetch[method.toLowerCase()] = (url, opts) => new Snekfetch(method, url, opts);
|
||||
Snekfetch[method.toLowerCase()] = function runMethod(url, opts) {
|
||||
const Constructor = this.prototype instanceof Snekfetch ? this : Snekfetch;
|
||||
return new Constructor(method, url, opts);
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = Snekfetch;
|
||||
|
|
@ -12957,7 +13100,7 @@ var objectKeys = Object.keys || function (obj) {
|
|||
/* 82 */
|
||||
/***/ (function(module, exports) {
|
||||
|
||||
module.exports = ({"version":"3.5.8","homepage":"https://snekfetch.js.org/"})
|
||||
module.exports = ({"version":"3.6.1","homepage":"https://snekfetch.js.org/"})
|
||||
|
||||
/***/ }),
|
||||
/* 83 */
|
||||
|
|
@ -12975,19 +13118,18 @@ function buildRequest(method, url) {
|
|||
getHeader(name) {
|
||||
return this.headers[name.toLowerCase()];
|
||||
},
|
||||
getHeaders() {
|
||||
return this.headers;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function finalizeRequest() {
|
||||
this._finalizeRequest();
|
||||
if (this.data) this.request.body = this.data;
|
||||
if (this.data)
|
||||
this.request.body = this.data;
|
||||
return window.fetch(this.request.path, this.request)
|
||||
.then((r) => r.text().then((t) => {
|
||||
const headers = {};
|
||||
for (const [k, v] of r.headers.entries()) headers[k.toLowerCase()] = v;
|
||||
for (const [k, v] of r.headers.entries())
|
||||
headers[k.toLowerCase()] = v;
|
||||
return { response: r, raw: t, headers };
|
||||
}));
|
||||
}
|
||||
|
|
|
|||
2
discord.voice-rewrite.min.js
vendored
2
discord.voice-rewrite.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue