mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-14 02:23:31 +01:00
refactor: ES2021 features (#6540)
Co-authored-by: Antonio Román <kyradiscord@gmail.com> Co-authored-by: Voltrex <mohammadkeyvanzade94@gmail.com>
This commit is contained in:
@@ -69,7 +69,7 @@ class Util extends null {
|
||||
* @param {SplitOptions} [options] Options controlling the behavior of the split
|
||||
* @returns {string[]}
|
||||
*/
|
||||
static splitMessage(text, { maxLength = 2000, char = '\n', prepend = '', append = '' } = {}) {
|
||||
static splitMessage(text, { maxLength = 2_000, char = '\n', prepend = '', append = '' } = {}) {
|
||||
text = Util.verifyString(text);
|
||||
if (text.length <= maxLength) return [text];
|
||||
let splitText = [text];
|
||||
@@ -181,7 +181,7 @@ class Util extends null {
|
||||
* @returns {string}
|
||||
*/
|
||||
static escapeCodeBlock(text) {
|
||||
return text.replace(/```/g, '\\`\\`\\`');
|
||||
return text.replaceAll('```', '\\`\\`\\`');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -243,7 +243,7 @@ class Util extends null {
|
||||
* @returns {string}
|
||||
*/
|
||||
static escapeStrikethrough(text) {
|
||||
return text.replace(/~~/g, '\\~\\~');
|
||||
return text.replaceAll('~~', '\\~\\~');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -252,7 +252,7 @@ class Util extends null {
|
||||
* @returns {string}
|
||||
*/
|
||||
static escapeSpoiler(text) {
|
||||
return text.replace(/\|\|/g, '\\|\\|');
|
||||
return text.replaceAll('||', '\\|\\|');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -267,7 +267,7 @@ class Util extends null {
|
||||
* @param {FetchRecommendedShardsOptions} [options] Options for fetching the recommended shard count
|
||||
* @returns {Promise<number>} The recommended number of shards
|
||||
*/
|
||||
static async fetchRecommendedShards(token, { guildsPerShard = 1000, multipleOf = 1 } = {}) {
|
||||
static async fetchRecommendedShards(token, { guildsPerShard = 1_000, multipleOf = 1 } = {}) {
|
||||
if (!token) throw new DiscordError('TOKEN_MISSING');
|
||||
const defaults = Options.createDefault();
|
||||
const response = await fetch(`${defaults.http.api}/v${defaults.http.version}${Endpoints.botGateway}`, {
|
||||
@@ -279,7 +279,7 @@ class Util extends null {
|
||||
throw response;
|
||||
}
|
||||
const { shards } = await response.json();
|
||||
return Math.ceil((shards * (1000 / guildsPerShard)) / multipleOf) * multipleOf;
|
||||
return Math.ceil((shards * (1_000 / guildsPerShard)) / multipleOf) * multipleOf;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -534,7 +534,7 @@ class Util extends null {
|
||||
bin = String(low & 1) + bin;
|
||||
low = Math.floor(low / 2);
|
||||
if (high > 0) {
|
||||
low += 5000000000 * (high % 2);
|
||||
low += 5_000_000_000 * (high % 2);
|
||||
high = Math.floor(high / 2);
|
||||
}
|
||||
}
|
||||
@@ -577,7 +577,7 @@ class Util extends null {
|
||||
* @returns {string}
|
||||
*/
|
||||
static removeMentions(str) {
|
||||
return str.replace(/@/g, '@\u200b');
|
||||
return str.replaceAll('@', '@\u200b');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -621,7 +621,7 @@ class Util extends null {
|
||||
* @returns {string}
|
||||
*/
|
||||
static cleanCodeBlockContent(text) {
|
||||
return text.replace(/```/g, '`\u200b``');
|
||||
return text.replaceAll('```', '`\u200b``');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user