mirror of
https://github.com/danbulant/discord.js
synced 2026-07-09 05:00:48 +00:00
Webpack build for branch master: bd154bdd9e
This commit is contained in:
parent
ce0e34e6df
commit
9569afff1c
2 changed files with 22 additions and 14 deletions
|
|
@ -1298,21 +1298,20 @@ class Util {
|
||||||
* @param {SplitOptions} [options] Options controlling the behaviour of the split
|
* @param {SplitOptions} [options] Options controlling the behaviour of the split
|
||||||
* @returns {string|string[]}
|
* @returns {string|string[]}
|
||||||
*/
|
*/
|
||||||
static splitMessage(text, { maxLength = 1950, char = '\n', prepend = '', append = '' } = {}) {
|
static splitMessage(text, { maxLength = 2000, char = '\n', prepend = '', append = '' } = {}) {
|
||||||
if (text.length <= maxLength) return text;
|
if (text.length <= maxLength) return text;
|
||||||
const splitText = text.split(char);
|
const splitText = text.split(char);
|
||||||
if (splitText.length === 1) throw new RangeError('SPLIT_MAX_LEN');
|
if (splitText.length === 1) throw new RangeError('SPLIT_MAX_LEN');
|
||||||
const messages = [''];
|
const messages = [];
|
||||||
let msg = 0;
|
let msg = '';
|
||||||
for (let i = 0; i < splitText.length; i++) {
|
for (const chunk of splitText) {
|
||||||
if (messages[msg].length + splitText[i].length + 1 > maxLength) {
|
if (msg && (msg + char + chunk + append).length > maxLength) {
|
||||||
messages[msg] += append;
|
messages.push(msg + append);
|
||||||
messages.push(prepend);
|
msg = prepend;
|
||||||
msg++;
|
|
||||||
}
|
}
|
||||||
messages[msg] += (messages[msg].length > 0 && messages[msg] !== prepend ? char : '') + splitText[i];
|
msg += (msg && msg !== prepend ? char : '') + chunk;
|
||||||
}
|
}
|
||||||
return messages.filter(m => m);
|
return messages.concat(msg).filter(m => m);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -1405,7 +1404,7 @@ class Util {
|
||||||
if (!has(given, key) || given[key] === undefined) {
|
if (!has(given, key) || given[key] === undefined) {
|
||||||
given[key] = def[key];
|
given[key] = def[key];
|
||||||
} else if (given[key] === Object(given[key])) {
|
} else if (given[key] === Object(given[key])) {
|
||||||
given[key] = this.mergeDefault(def[key], given[key]);
|
given[key] = Util.mergeDefault(def[key], given[key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1419,7 +1418,7 @@ class Util {
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
static convertToBuffer(ab) {
|
static convertToBuffer(ab) {
|
||||||
if (typeof ab === 'string') ab = this.str2ab(ab);
|
if (typeof ab === 'string') ab = Util.str2ab(ab);
|
||||||
return Buffer.from(ab);
|
return Buffer.from(ab);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -12674,7 +12673,7 @@ class ClientPresenceStore extends PresenceStore {
|
||||||
since: since != null ? since : null, // eslint-disable-line eqeqeq
|
since: since != null ? since : null, // eslint-disable-line eqeqeq
|
||||||
status: status || this.clientPresence.status,
|
status: status || this.clientPresence.status,
|
||||||
game: activity ? {
|
game: activity ? {
|
||||||
type: typeof activity.type === 'number' ? activity.type : ActivityTypes.indexOf(activity.type),
|
type: activity.type,
|
||||||
name: activity.name,
|
name: activity.name,
|
||||||
url: activity.url,
|
url: activity.url,
|
||||||
details: activity.details || undefined,
|
details: activity.details || undefined,
|
||||||
|
|
@ -12693,6 +12692,15 @@ class ClientPresenceStore extends PresenceStore {
|
||||||
} : null,
|
} : null,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if ((status || afk || since) && !activity) {
|
||||||
|
packet.game = this.clientPresence.activity;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (packet.game) {
|
||||||
|
packet.game.type = typeof packet.game.type === 'number' ?
|
||||||
|
packet.game.type : ActivityTypes.indexOf(packet.game.type);
|
||||||
|
}
|
||||||
|
|
||||||
this.clientPresence.patch(packet);
|
this.clientPresence.patch(packet);
|
||||||
this.client.ws.send({ op: OPCodes.STATUS_UPDATE, d: packet });
|
this.client.ws.send({ op: OPCodes.STATUS_UPDATE, d: packet });
|
||||||
return this.clientPresence;
|
return this.clientPresence;
|
||||||
|
|
|
||||||
2
discord.master.min.js
vendored
2
discord.master.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue