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:
Rodry
2021-09-03 12:58:01 +01:00
committed by GitHub
parent d81590d566
commit 00bd92a451
35 changed files with 145 additions and 156 deletions

View File

@@ -181,7 +181,7 @@ class Client extends BaseClient {
); );
this.sweepMessageInterval = setInterval( this.sweepMessageInterval = setInterval(
this.sweepMessages.bind(this), this.sweepMessages.bind(this),
this.options.messageSweepInterval * 1000, this.options.messageSweepInterval * 1_000,
).unref(); ).unref();
} }
} }
@@ -401,7 +401,7 @@ class Client extends BaseClient {
return -1; return -1;
} }
const lifetimeMs = lifetime * 1000; const lifetimeMs = lifetime * 1_000;
const now = Date.now(); const now = Date.now();
let channels = 0; let channels = 0;
let messages = 0; let messages = 0;

View File

@@ -2,6 +2,7 @@
const EventEmitter = require('events'); const EventEmitter = require('events');
const { Collection } = require('@discordjs/collection'); const { Collection } = require('@discordjs/collection');
const { RPCErrorCodes } = require('discord-api-types/v9');
const WebSocketShard = require('./WebSocketShard'); const WebSocketShard = require('./WebSocketShard');
const PacketHandlers = require('./handlers'); const PacketHandlers = require('./handlers');
const { Error } = require('../../errors'); const { Error } = require('../../errors');
@@ -19,7 +20,11 @@ const BeforeReadyWhitelist = [
]; ];
const UNRECOVERABLE_CLOSE_CODES = Object.keys(WSCodes).slice(1).map(Number); const UNRECOVERABLE_CLOSE_CODES = Object.keys(WSCodes).slice(1).map(Number);
const UNRESUMABLE_CLOSE_CODES = [1000, 4006, 4007]; const UNRESUMABLE_CLOSE_CODES = [
RPCErrorCodes.UnknownError,
RPCErrorCodes.InvalidPermissions,
RPCErrorCodes.InvalidClientId,
];
/** /**
* The WebSocket manager for this client. * The WebSocket manager for this client.
@@ -184,7 +189,7 @@ class WebSocketManager extends EventEmitter {
}); });
shard.on(ShardEvents.CLOSE, event => { shard.on(ShardEvents.CLOSE, event => {
if (event.code === 1000 ? this.destroyed : UNRECOVERABLE_CLOSE_CODES.includes(event.code)) { if (event.code === 1_000 ? this.destroyed : UNRECOVERABLE_CLOSE_CODES.includes(event.code)) {
/** /**
* Emitted when a shard's WebSocket disconnects and will no longer reconnect. * Emitted when a shard's WebSocket disconnects and will no longer reconnect.
* @event Client#shardDisconnect * @event Client#shardDisconnect
@@ -253,7 +258,7 @@ class WebSocketManager extends EventEmitter {
// If we have more shards, add a 5s delay // If we have more shards, add a 5s delay
if (this.shardQueue.size) { if (this.shardQueue.size) {
this.debug(`Shard Queue Size: ${this.shardQueue.size}; continuing in 5 seconds...`); this.debug(`Shard Queue Size: ${this.shardQueue.size}; continuing in 5 seconds...`);
await Util.delayFor(5000); await Util.delayFor(5_000);
return this.createShards(); return this.createShards();
} }
@@ -274,7 +279,7 @@ class WebSocketManager extends EventEmitter {
this.debug(`Couldn't reconnect or fetch information about the gateway. ${error}`); this.debug(`Couldn't reconnect or fetch information about the gateway. ${error}`);
if (error.httpStatus !== 401) { if (error.httpStatus !== 401) {
this.debug(`Possible network error occurred. Retrying in 5s...`); this.debug(`Possible network error occurred. Retrying in 5s...`);
await Util.delayFor(5000); await Util.delayFor(5_000);
this.reconnecting = false; this.reconnecting = false;
return this.reconnect(); return this.reconnect();
} }
@@ -316,7 +321,7 @@ class WebSocketManager extends EventEmitter {
this.debug(`Manager was destroyed. Called by:\n${new Error('MANAGER_DESTROYED').stack}`); this.debug(`Manager was destroyed. Called by:\n${new Error('MANAGER_DESTROYED').stack}`);
this.destroyed = true; this.destroyed = true;
this.shardQueue.clear(); this.shardQueue.clear();
for (const shard of this.shards.values()) shard.destroy({ closeCode: 1000, reset: true, emit: false, log: false }); for (const shard of this.shards.values()) shard.destroy({ closeCode: 1_000, reset: true, emit: false, log: false });
} }
/** /**

View File

@@ -415,7 +415,7 @@ class WebSocketShard extends EventEmitter {
break; break;
case Opcodes.RECONNECT: case Opcodes.RECONNECT:
this.debug('[RECONNECT] Discord asked us to reconnect'); this.debug('[RECONNECT] Discord asked us to reconnect');
this.destroy({ closeCode: 4000 }); this.destroy({ closeCode: 4_000 });
break; break;
case Opcodes.INVALID_SESSION: case Opcodes.INVALID_SESSION:
this.debug(`[INVALID SESSION] Resumable: ${packet.d}.`); this.debug(`[INVALID SESSION] Resumable: ${packet.d}.`);
@@ -489,7 +489,7 @@ class WebSocketShard extends EventEmitter {
this.emit(ShardEvents.ALL_READY, this.expectedGuilds); this.emit(ShardEvents.ALL_READY, this.expectedGuilds);
}, },
hasGuildsIntent ? 15000 : 0, hasGuildsIntent ? 15_000 : 0,
).unref(); ).unref();
} }
@@ -511,7 +511,7 @@ class WebSocketShard extends EventEmitter {
this.helloTimeout = setTimeout(() => { this.helloTimeout = setTimeout(() => {
this.debug('Did not receive HELLO in time. Destroying and connecting again.'); this.debug('Did not receive HELLO in time. Destroying and connecting again.');
this.destroy({ reset: true, closeCode: 4009 }); this.destroy({ reset: true, closeCode: 4009 });
}, 20000).unref(); }, 20_000).unref();
} }
/** /**
@@ -656,7 +656,7 @@ class WebSocketShard extends EventEmitter {
_send(data) { _send(data) {
if (this.connection?.readyState !== WebSocket.OPEN) { if (this.connection?.readyState !== WebSocket.OPEN) {
this.debug(`Tried to send packet '${JSON.stringify(data)}' but no WebSocket is available!`); this.debug(`Tried to send packet '${JSON.stringify(data)}' but no WebSocket is available!`);
this.destroy({ closeCode: 4000 }); this.destroy({ closeCode: 4_000 });
return; return;
} }
@@ -692,7 +692,7 @@ class WebSocketShard extends EventEmitter {
* @param {Object} [options={ closeCode: 1000, reset: false, emit: true, log: true }] Options for destroying the shard * @param {Object} [options={ closeCode: 1000, reset: false, emit: true, log: true }] Options for destroying the shard
* @private * @private
*/ */
destroy({ closeCode = 1000, reset = false, emit = true, log = true } = {}) { destroy({ closeCode = 1_000, reset = false, emit = true, log = true } = {}) {
if (log) { if (log) {
this.debug(`[DESTROY] this.debug(`[DESTROY]
Close Code : ${closeCode} Close Code : ${closeCode}

View File

@@ -380,9 +380,7 @@ class ApplicationCommandPermissionsManager extends BaseManager {
if (!commandId && this.guild) { if (!commandId && this.guild) {
commandId = this.guild.commands.resolveId(command); commandId = this.guild.commands.resolveId(command);
} }
if (!commandId) { commandId ??= this.client.application?.commands.resolveId(command);
commandId = this.client.application?.commands.resolveId(command);
}
if (!commandId) { if (!commandId) {
throw new TypeError('INVALID_TYPE', 'command', 'ApplicationCommandResolvable', true); throw new TypeError('INVALID_TYPE', 'command', 'ApplicationCommandResolvable', true);
} }

View File

@@ -238,7 +238,7 @@ class GuildManager extends CachedManager {
this.client.removeListener(Events.GUILD_CREATE, handleGuild); this.client.removeListener(Events.GUILD_CREATE, handleGuild);
this.client.decrementMaxListeners(); this.client.decrementMaxListeners();
resolve(this.client.guilds._add(data)); resolve(this.client.guilds._add(data));
}, 10000).unref(); }, 10_000).unref();
}); });
} }

View File

@@ -420,7 +420,7 @@ class GuildMemberManager extends CachedManager {
for (const member of members.values()) { for (const member of members.values()) {
fetchedMembers.set(member.id, member); fetchedMembers.set(member.id, member);
} }
if (members.size < 1000 || (limit && fetchedMembers.size >= limit) || i === chunk.count) { if (members.size < 1_000 || (limit && fetchedMembers.size >= limit) || i === chunk.count) {
clearTimeout(timeout); clearTimeout(timeout);
this.client.removeListener(Events.GUILD_MEMBERS_CHUNK, handler); this.client.removeListener(Events.GUILD_MEMBERS_CHUNK, handler);
this.client.decrementMaxListeners(); this.client.decrementMaxListeners();

View File

@@ -19,7 +19,7 @@ class RESTManager {
if (client.options.restSweepInterval > 0) { if (client.options.restSweepInterval > 0) {
this.sweepInterval = setInterval(() => { this.sweepInterval = setInterval(() => {
this.handlers.sweep(handler => handler._inactive); this.handlers.sweep(handler => handler._inactive);
}, client.options.restSweepInterval * 1000).unref(); }, client.options.restSweepInterval * 1_000).unref();
} }
} }

View File

@@ -21,9 +21,9 @@ function getAPIOffset(serverDate) {
function calculateReset(reset, resetAfter, serverDate) { function calculateReset(reset, resetAfter, serverDate) {
// Use direct reset time when available, server date becomes irrelevant in this case // Use direct reset time when available, server date becomes irrelevant in this case
if (resetAfter) { if (resetAfter) {
return Date.now() + Number(resetAfter) * 1000; return Date.now() + Number(resetAfter) * 1_000;
} }
return new Date(Number(reset) * 1000).getTime() - getAPIOffset(serverDate); return new Date(Number(reset) * 1_000).getTime() - getAPIOffset(serverDate);
} }
/* Invalid request limiting is done on a per-IP basis, not a per-token basis. /* Invalid request limiting is done on a per-IP basis, not a per-token basis.
@@ -157,7 +157,7 @@ class RequestHandler {
// As the request goes out, update the global usage information // As the request goes out, update the global usage information
if (!this.manager.globalReset || this.manager.globalReset < Date.now()) { if (!this.manager.globalReset || this.manager.globalReset < Date.now()) {
this.manager.globalReset = Date.now() + 1000; this.manager.globalReset = Date.now() + 1_000;
this.manager.globalRemaining = this.manager.globalLimit; this.manager.globalRemaining = this.manager.globalLimit;
} }
this.manager.globalRemaining--; this.manager.globalRemaining--;
@@ -195,7 +195,7 @@ class RequestHandler {
// Handle retryAfter, which means we have actually hit a rate limit // Handle retryAfter, which means we have actually hit a rate limit
let retryAfter = res.headers.get('retry-after'); let retryAfter = res.headers.get('retry-after');
retryAfter = retryAfter ? Number(retryAfter) * 1000 : -1; retryAfter = retryAfter ? Number(retryAfter) * 1_000 : -1;
if (retryAfter > 0) { if (retryAfter > 0) {
// If the global ratelimit header is set, that means we hit the global rate limit // If the global ratelimit header is set, that means we hit the global rate limit
if (res.headers.get('x-ratelimit-global')) { if (res.headers.get('x-ratelimit-global')) {
@@ -215,7 +215,7 @@ class RequestHandler {
// Count the invalid requests // Count the invalid requests
if (res.status === 401 || res.status === 403 || res.status === 429) { if (res.status === 401 || res.status === 403 || res.status === 429) {
if (!invalidCountResetTime || invalidCountResetTime < Date.now()) { if (!invalidCountResetTime || invalidCountResetTime < Date.now()) {
invalidCountResetTime = Date.now() + 1000 * 60 * 10; invalidCountResetTime = Date.now() + 1_000 * 60 * 10;
invalidCount = 0; invalidCount = 0;
} }
invalidCount++; invalidCount++;

View File

@@ -106,7 +106,7 @@ class Shard extends EventEmitter {
* before resolving (`-1` or `Infinity` for no wait) * before resolving (`-1` or `Infinity` for no wait)
* @returns {Promise<ChildProcess>} * @returns {Promise<ChildProcess>}
*/ */
spawn(timeout = 30000) { spawn(timeout = 30_000) {
if (this.process) throw new Error('SHARDING_PROCESS_EXISTS', this.id); if (this.process) throw new Error('SHARDING_PROCESS_EXISTS', this.id);
if (this.worker) throw new Error('SHARDING_WORKER_EXISTS', this.id); if (this.worker) throw new Error('SHARDING_WORKER_EXISTS', this.id);
@@ -201,7 +201,7 @@ class Shard extends EventEmitter {
* @param {ShardRespawnOptions} [options] Options for respawning the shard * @param {ShardRespawnOptions} [options] Options for respawning the shard
* @returns {Promise<ChildProcess>} * @returns {Promise<ChildProcess>}
*/ */
async respawn({ delay = 500, timeout = 30000 } = {}) { async respawn({ delay = 500, timeout = 30_000 } = {}) {
this.kill(); this.kill();
if (delay > 0) await Util.delayFor(delay); if (delay > 0) await Util.delayFor(delay);
return this.spawn(timeout); return this.spawn(timeout);

View File

@@ -167,7 +167,7 @@ class ShardClientUtil {
* @returns {Promise<void>} Resolves upon the message being sent * @returns {Promise<void>} Resolves upon the message being sent
* @see {@link ShardingManager#respawnAll} * @see {@link ShardingManager#respawnAll}
*/ */
respawnAll({ shardDelay = 5000, respawnDelay = 500, timeout = 30000 } = {}) { respawnAll({ shardDelay = 5_000, respawnDelay = 500, timeout = 30_000 } = {}) {
return this.send({ _sRespawnAll: { shardDelay, respawnDelay, timeout } }); return this.send({ _sRespawnAll: { shardDelay, respawnDelay, timeout } });
} }

View File

@@ -178,7 +178,7 @@ class ShardingManager extends EventEmitter {
* @param {MultipleShardSpawnOptions} [options] Options for spawning shards * @param {MultipleShardSpawnOptions} [options] Options for spawning shards
* @returns {Promise<Collection<number, Shard>>} * @returns {Promise<Collection<number, Shard>>}
*/ */
async spawn({ amount = this.totalShards, delay = 5500, timeout = 30000 } = {}) { async spawn({ amount = this.totalShards, delay = 5500, timeout = 30_000 } = {}) {
// Obtain/verify the number of shards to spawn // Obtain/verify the number of shards to spawn
if (amount === 'auto') { if (amount === 'auto') {
amount = await Util.fetchRecommendedShards(this.token); amount = await Util.fetchRecommendedShards(this.token);
@@ -302,7 +302,7 @@ class ShardingManager extends EventEmitter {
* @param {MultipleShardRespawnOptions} [options] Options for respawning shards * @param {MultipleShardRespawnOptions} [options] Options for respawning shards
* @returns {Promise<Collection<string, Shard>>} * @returns {Promise<Collection<string, Shard>>}
*/ */
async respawnAll({ shardDelay = 5000, respawnDelay = 500, timeout = 30000 } = {}) { async respawnAll({ shardDelay = 5_000, respawnDelay = 500, timeout = 30_000 } = {}) {
let s = 0; let s = 0;
for (const shard of this.shards.values()) { for (const shard of this.shards.values()) {
const promises = [shard.respawn({ respawnDelay, timeout })]; const promises = [shard.respawn({ respawnDelay, timeout })];

View File

@@ -133,14 +133,14 @@ class Channel extends Base {
} }
static create(client, data, guild, { allowUnknownGuild, fromInteraction } = {}) { static create(client, data, guild, { allowUnknownGuild, fromInteraction } = {}) {
if (!CategoryChannel) CategoryChannel = require('./CategoryChannel'); CategoryChannel ??= require('./CategoryChannel');
if (!DMChannel) DMChannel = require('./DMChannel'); DMChannel ??= require('./DMChannel');
if (!NewsChannel) NewsChannel = require('./NewsChannel'); NewsChannel ??= require('./NewsChannel');
if (!StageChannel) StageChannel = require('./StageChannel'); StageChannel ??= require('./StageChannel');
if (!StoreChannel) StoreChannel = require('./StoreChannel'); StoreChannel ??= require('./StoreChannel');
if (!TextChannel) TextChannel = require('./TextChannel'); TextChannel ??= require('./TextChannel');
if (!ThreadChannel) ThreadChannel = require('./ThreadChannel'); ThreadChannel ??= require('./ThreadChannel');
if (!VoiceChannel) VoiceChannel = require('./VoiceChannel'); VoiceChannel ??= require('./VoiceChannel');
let channel; let channel;
if (!data.guild_id && !guild) { if (!data.guild_id && !guild) {
@@ -151,7 +151,7 @@ class Channel extends Base {
channel = new PartialGroupDMChannel(client, data); channel = new PartialGroupDMChannel(client, data);
} }
} else { } else {
if (!guild) guild = client.guilds.cache.get(data.guild_id); guild ??= client.guilds.cache.get(data.guild_id);
if (guild || allowUnknownGuild) { if (guild || allowUnknownGuild) {
switch (data.type) { switch (data.type) {

View File

@@ -53,7 +53,7 @@ class ClientPresence extends Presence {
if (activities?.length) { if (activities?.length) {
for (const [i, activity] of activities.entries()) { for (const [i, activity] of activities.entries()) {
if (typeof activity.name !== 'string') throw new TypeError('INVALID_TYPE', `activities[${i}].name`, 'string'); if (typeof activity.name !== 'string') throw new TypeError('INVALID_TYPE', `activities[${i}].name`, 'string');
if (!activity.type) activity.type = 0; activity.type ??= 0;
data.activities.push({ data.activities.push({
type: typeof activity.type === 'number' ? activity.type : ActivityTypes[activity.type], type: typeof activity.type === 'number' ? activity.type : ActivityTypes[activity.type],

View File

@@ -25,8 +25,8 @@ class ClientUser extends User {
* @type {?boolean} * @type {?boolean}
*/ */
this.mfaEnabled = typeof data.mfa_enabled === 'boolean' ? data.mfa_enabled : null; this.mfaEnabled = typeof data.mfa_enabled === 'boolean' ? data.mfa_enabled : null;
} else if (typeof this.mfaEnabled === 'undefined') { } else {
this.mfaEnabled = null; this.mfaEnabled ??= null;
} }
if (data.token) this.client.token = data.token; if (data.token) this.client.token = data.token;

View File

@@ -279,8 +279,8 @@ class Guild extends AnonymousGuild {
* @type {?number} * @type {?number}
*/ */
this.maximumMembers = data.max_members; this.maximumMembers = data.max_members;
} else if (typeof this.maximumMembers === 'undefined') { } else {
this.maximumMembers = null; this.maximumMembers ??= null;
} }
if (typeof data.max_presences !== 'undefined') { if (typeof data.max_presences !== 'undefined') {
@@ -289,9 +289,9 @@ class Guild extends AnonymousGuild {
* <info>You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter</info> * <info>You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter</info>
* @type {?number} * @type {?number}
*/ */
this.maximumPresences = data.max_presences ?? 25000; this.maximumPresences = data.max_presences ?? 25_000;
} else if (typeof this.maximumPresences === 'undefined') { } else {
this.maximumPresences = null; this.maximumPresences ??= null;
} }
if (typeof data.approximate_member_count !== 'undefined') { if (typeof data.approximate_member_count !== 'undefined') {
@@ -301,8 +301,8 @@ class Guild extends AnonymousGuild {
* @type {?number} * @type {?number}
*/ */
this.approximateMemberCount = data.approximate_member_count; this.approximateMemberCount = data.approximate_member_count;
} else if (typeof this.approximateMemberCount === 'undefined') { } else {
this.approximateMemberCount = null; this.approximateMemberCount ??= null;
} }
if (typeof data.approximate_presence_count !== 'undefined') { if (typeof data.approximate_presence_count !== 'undefined') {
@@ -312,8 +312,8 @@ class Guild extends AnonymousGuild {
* @type {?number} * @type {?number}
*/ */
this.approximatePresenceCount = data.approximate_presence_count; this.approximatePresenceCount = data.approximate_presence_count;
} else if (typeof this.approximatePresenceCount === 'undefined') { } else {
this.approximatePresenceCount = null; this.approximatePresenceCount ??= null;
} }
/** /**
@@ -541,18 +541,18 @@ class Guild extends AnonymousGuild {
*/ */
get maximumBitrate() { get maximumBitrate() {
if (this.features.includes('VIP_REGIONS')) { if (this.features.includes('VIP_REGIONS')) {
return 384000; return 384_000;
} }
switch (PremiumTiers[this.premiumTier]) { switch (PremiumTiers[this.premiumTier]) {
case PremiumTiers.TIER_1: case PremiumTiers.TIER_1:
return 128000; return 128_000;
case PremiumTiers.TIER_2: case PremiumTiers.TIER_2:
return 256000; return 256_000;
case PremiumTiers.TIER_3: case PremiumTiers.TIER_3:
return 384000; return 384_000;
default: default:
return 96000; return 96_000;
} }
} }

View File

@@ -172,7 +172,7 @@ class GuildChannel extends Channel {
if (!verified) member = this.guild.members.resolve(member); if (!verified) member = this.guild.members.resolve(member);
if (!member) return []; if (!member) return [];
if (!roles) roles = member.roles.cache; roles ??= member.roles.cache;
const roleOverwrites = []; const roleOverwrites = [];
let memberOverwrites; let memberOverwrites;
let everyoneOverwrites; let everyoneOverwrites;

View File

@@ -129,7 +129,7 @@ class GuildTemplate extends Base {
client.incrementMaxListeners(); client.incrementMaxListeners();
client.on(Events.GUILD_CREATE, handleGuild); client.on(Events.GUILD_CREATE, handleGuild);
const timeout = setTimeout(() => resolveGuild(client.guilds._add(data)), 10000).unref(); const timeout = setTimeout(() => resolveGuild(client.guilds._add(data)), 10_000).unref();
}); });
} }

View File

@@ -116,8 +116,8 @@ class Integration extends Base {
*/ */
this.application = new IntegrationApplication(this.client, data.application); this.application = new IntegrationApplication(this.client, data.application);
} }
} else if (!this.application) { } else {
this.application = null; this.application ??= null;
} }
} }

View File

@@ -162,7 +162,7 @@ class Invite extends Base {
get expiresTimestamp() { get expiresTimestamp() {
return ( return (
this._expiresTimestamp ?? this._expiresTimestamp ??
(this.createdTimestamp && this.maxAge ? this.createdTimestamp + this.maxAge * 1000 : null) (this.createdTimestamp && this.maxAge ? this.createdTimestamp + this.maxAge * 1_000 : null)
); );
} }

View File

@@ -92,8 +92,8 @@ class Message extends Base {
* @type {?User} * @type {?User}
*/ */
this.author = this.client.users._add(data.author, !data.webhook_id); this.author = this.client.users._add(data.author, !data.webhook_id);
} else if (!this.author) { } else {
this.author = null; this.author ??= null;
} }
if ('pinned' in data) { if ('pinned' in data) {
@@ -102,8 +102,8 @@ class Message extends Base {
* @type {?boolean} * @type {?boolean}
*/ */
this.pinned = Boolean(data.pinned); this.pinned = Boolean(data.pinned);
} else if (typeof this.pinned !== 'boolean') { } else {
this.pinned = null; this.pinned ??= null;
} }
if ('tts' in data) { if ('tts' in data) {
@@ -112,8 +112,8 @@ class Message extends Base {
* @type {?boolean} * @type {?boolean}
*/ */
this.tts = data.tts; this.tts = data.tts;
} else if (typeof this.tts !== 'boolean') { } else {
this.tts = null; this.tts ??= null;
} }
if (!partial) { if (!partial) {
@@ -334,8 +334,8 @@ class Message extends Base {
commandName: data.interaction.name, commandName: data.interaction.name,
user: this.client.users._add(data.interaction.user), user: this.client.users._add(data.interaction.user),
}; };
} else if (!this.interaction) { } else {
this.interaction = null; this.interaction ??= null;
} }
} }
@@ -447,7 +447,7 @@ class Message extends Base {
* @example * @example
* // Create a reaction collector * // Create a reaction collector
* const filter = (reaction, user) => reaction.emoji.name === '👌' && user.id === 'someId'; * const filter = (reaction, user) => reaction.emoji.name === '👌' && user.id === 'someId';
* const collector = message.createReactionCollector({ filter, time: 15000 }); * const collector = message.createReactionCollector({ filter, time: 15_000 });
* collector.on('collect', r => console.log(`Collected ${r.emoji.name}`)); * collector.on('collect', r => console.log(`Collected ${r.emoji.name}`));
* collector.on('end', collected => console.log(`Collected ${collected.size} items`)); * collector.on('end', collected => console.log(`Collected ${collected.size} items`));
*/ */
@@ -469,7 +469,7 @@ class Message extends Base {
* @example * @example
* // Create a reaction collector * // Create a reaction collector
* const filter = (reaction, user) => reaction.emoji.name === '👌' && user.id === 'someId' * const filter = (reaction, user) => reaction.emoji.name === '👌' && user.id === 'someId'
* message.awaitReactions({ filter, time: 15000 }) * message.awaitReactions({ filter, time: 15_000 })
* .then(collected => console.log(`Collected ${collected.size} reactions`)) * .then(collected => console.log(`Collected ${collected.size} reactions`))
* .catch(console.error); * .catch(console.error);
*/ */
@@ -498,7 +498,7 @@ class Message extends Base {
* @example * @example
* // Create a message component interaction collector * // Create a message component interaction collector
* const filter = (interaction) => interaction.customId === 'button' && interaction.user.id === 'someId'; * const filter = (interaction) => interaction.customId === 'button' && interaction.user.id === 'someId';
* const collector = message.createMessageComponentCollector({ filter, time: 15000 }); * const collector = message.createMessageComponentCollector({ filter, time: 15_000 });
* collector.on('collect', i => console.log(`Collected ${i.customId}`)); * collector.on('collect', i => console.log(`Collected ${i.customId}`));
* collector.on('end', collected => console.log(`Collected ${collected.size} items`)); * collector.on('end', collected => console.log(`Collected ${collected.size} items`));
*/ */
@@ -526,7 +526,7 @@ class Message extends Base {
* @example * @example
* // Collect a message component interaction * // Collect a message component interaction
* const filter = (interaction) => interaction.customId === 'button' && interaction.user.id === 'someId'; * const filter = (interaction) => interaction.customId === 'button' && interaction.user.id === 'someId';
* message.awaitMessageComponent({ filter, time: 15000 }) * message.awaitMessageComponent({ filter, time: 15_000 })
* .then(interaction => console.log(`${interaction.customId} was clicked!`)) * .then(interaction => console.log(`${interaction.customId} was clicked!`))
* .catch(console.error); * .catch(console.error);
*/ */

View File

@@ -120,7 +120,7 @@ class MessageReaction {
if (this.partial) return; if (this.partial) return;
this.users.cache.set(user.id, user); this.users.cache.set(user.id, user);
if (!this.me || user.id !== this.message.client.user.id || this.count === 0) this.count++; if (!this.me || user.id !== this.message.client.user.id || this.count === 0) this.count++;
if (!this.me) this.me = user.id === this.message.client.user.id; this.me ??= user.id === this.message.client.user.id;
} }
_remove(user) { _remove(user) {

View File

@@ -67,8 +67,8 @@ class ThreadChannel extends Channel {
* @type {?Snowflake} * @type {?Snowflake}
*/ */
this.parentId = data.parent_id; this.parentId = data.parent_id;
} else if (!this.parentId) { } else {
this.parentId = null; this.parentId ??= null;
} }
if ('thread_metadata' in data) { if ('thread_metadata' in data) {
@@ -105,18 +105,10 @@ class ThreadChannel extends Channel {
*/ */
this.archiveTimestamp = new Date(data.thread_metadata.archive_timestamp).getTime(); this.archiveTimestamp = new Date(data.thread_metadata.archive_timestamp).getTime();
} else { } else {
if (!this.locked) { this.locked ??= null;
this.locked = null; this.archived ??= null;
} this.autoArchiveDuration ??= null;
if (!this.archived) { this.archiveTimestamp ??= null;
this.archived = null;
}
if (!this.autoArchiveDuration) {
this.autoArchiveDuration = null;
}
if (!this.archiveTimestamp) {
this.archiveTimestamp = null;
}
this.invitable ??= null; this.invitable ??= null;
} }
@@ -126,8 +118,8 @@ class ThreadChannel extends Channel {
* @type {?Snowflake} * @type {?Snowflake}
*/ */
this.ownerId = data.owner_id; this.ownerId = data.owner_id;
} else if (!this.ownerId) { } else {
this.ownerId = null; this.ownerId ??= null;
} }
if ('last_message_id' in data) { if ('last_message_id' in data) {
@@ -136,8 +128,8 @@ class ThreadChannel extends Channel {
* @type {?Snowflake} * @type {?Snowflake}
*/ */
this.lastMessageId = data.last_message_id; this.lastMessageId = data.last_message_id;
} else if (!this.lastMessageId) { } else {
this.lastMessageId = null; this.lastMessageId ??= null;
} }
if ('last_pin_timestamp' in data) { if ('last_pin_timestamp' in data) {
@@ -146,8 +138,8 @@ class ThreadChannel extends Channel {
* @type {?number} * @type {?number}
*/ */
this.lastPinTimestamp = data.last_pin_timestamp ? new Date(data.last_pin_timestamp).getTime() : null; this.lastPinTimestamp = data.last_pin_timestamp ? new Date(data.last_pin_timestamp).getTime() : null;
} else if (!this.lastPinTimestamp) { } else {
this.lastPinTimestamp = null; this.lastPinTimestamp ??= null;
} }
if ('rate_limit_per_user' in data || !partial) { if ('rate_limit_per_user' in data || !partial) {
@@ -156,8 +148,8 @@ class ThreadChannel extends Channel {
* @type {?number} * @type {?number}
*/ */
this.rateLimitPerUser = data.rate_limit_per_user ?? 0; this.rateLimitPerUser = data.rate_limit_per_user ?? 0;
} else if (!this.rateLimitPerUser) { } else {
this.rateLimitPerUser = null; this.rateLimitPerUser ??= null;
} }
if ('message_count' in data) { if ('message_count' in data) {
@@ -168,8 +160,8 @@ class ThreadChannel extends Channel {
* @type {?number} * @type {?number}
*/ */
this.messageCount = data.message_count; this.messageCount = data.message_count;
} else if (!this.messageCount) { } else {
this.messageCount = null; this.messageCount ??= null;
} }
if ('member_count' in data) { if ('member_count' in data) {
@@ -180,8 +172,8 @@ class ThreadChannel extends Channel {
* @type {?number} * @type {?number}
*/ */
this.memberCount = data.member_count; this.memberCount = data.member_count;
} else if (!this.memberCount) { } else {
this.memberCount = null; this.memberCount ??= null;
} }
if (data.member && this.client.user) this.members._add({ user_id: this.client.user.id, ...data.member }); if (data.member && this.client.user) this.members._add({ user_id: this.client.user.id, ...data.member });

View File

@@ -35,7 +35,7 @@ class Typing extends Base {
* The UNIX timestamp in milliseconds the user started typing at * The UNIX timestamp in milliseconds the user started typing at
* @type {number} * @type {number}
*/ */
this.startedTimestamp = data.timestamp * 1000; this.startedTimestamp = data.timestamp * 1_000;
} }
/** /**

View File

@@ -93,8 +93,8 @@ class User extends Base {
* @type {?number} * @type {?number}
*/ */
this.accentColor = data.accent_color; this.accentColor = data.accent_color;
} else if (typeof this.accentColor === 'undefined') { } else {
this.accentColor = null; this.accentColor ??= null;
} }
if ('system' in data) { if ('system' in data) {

View File

@@ -53,7 +53,7 @@ class VoiceChannel extends BaseGuildVoiceChannel {
* @returns {Promise<VoiceChannel>} * @returns {Promise<VoiceChannel>}
* @example * @example
* // Set the bitrate of a voice channel * // Set the bitrate of a voice channel
* voiceChannel.setBitrate(48000) * voiceChannel.setBitrate(48_000)
* .then(vc => console.log(`Set bitrate to ${vc.bitrate}bps for ${vc.name}`)) * .then(vc => console.log(`Set bitrate to ${vc.bitrate}bps for ${vc.name}`))
* .catch(console.error); * .catch(console.error);
*/ */

View File

@@ -189,7 +189,7 @@ class Webhook {
* 'color': '#F0F', * 'color': '#F0F',
* 'footer_icon': 'http://snek.s3.amazonaws.com/topSnek.png', * 'footer_icon': 'http://snek.s3.amazonaws.com/topSnek.png',
* 'footer': 'Powered by sneks', * 'footer': 'Powered by sneks',
* 'ts': Date.now() / 1000 * 'ts': Date.now() / 1_000
* }] * }]
* }).catch(console.error); * }).catch(console.error);
* @see {@link https://api.slack.com/messaging/webhooks} * @see {@link https://api.slack.com/messaging/webhooks}

View File

@@ -198,7 +198,7 @@ class TextBasedChannel {
* @example * @example
* // Create a message collector * // Create a message collector
* const filter = m => m.content.includes('discord'); * const filter = m => m.content.includes('discord');
* const collector = channel.createMessageCollector({ filter, time: 15000 }); * const collector = channel.createMessageCollector({ filter, time: 15_000 });
* collector.on('collect', m => console.log(`Collected ${m.content}`)); * collector.on('collect', m => console.log(`Collected ${m.content}`));
* collector.on('end', collected => console.log(`Collected ${collected.size} items`)); * collector.on('end', collected => console.log(`Collected ${collected.size} items`));
*/ */
@@ -221,7 +221,7 @@ class TextBasedChannel {
* // Await !vote messages * // Await !vote messages
* const filter = m => m.content.startsWith('!vote'); * const filter = m => m.content.startsWith('!vote');
* // Errors: ['time'] treats ending because of the time limit as an error * // Errors: ['time'] treats ending because of the time limit as an error
* channel.awaitMessages({ filter, max: 4, time: 60000, errors: ['time'] }) * channel.awaitMessages({ filter, max: 4, time: 60_000, errors: ['time'] })
* .then(collected => console.log(collected.size)) * .then(collected => console.log(collected.size))
* .catch(collected => console.log(`After a minute, only ${collected.size} out of 4 voted.`)); * .catch(collected => console.log(`After a minute, only ${collected.size} out of 4 voted.`));
*/ */
@@ -245,7 +245,7 @@ class TextBasedChannel {
* @example * @example
* // Create a button interaction collector * // Create a button interaction collector
* const filter = (interaction) => interaction.customId === 'button' && interaction.user.id === 'someId'; * const filter = (interaction) => interaction.customId === 'button' && interaction.user.id === 'someId';
* const collector = channel.createMessageComponentCollector({ filter, time: 15000 }); * const collector = channel.createMessageComponentCollector({ filter, time: 15_000 });
* collector.on('collect', i => console.log(`Collected ${i.customId}`)); * collector.on('collect', i => console.log(`Collected ${i.customId}`));
* collector.on('end', collected => console.log(`Collected ${collected.size} items`)); * collector.on('end', collected => console.log(`Collected ${collected.size} items`));
*/ */
@@ -265,7 +265,7 @@ class TextBasedChannel {
* @example * @example
* // Collect a message component interaction * // Collect a message component interaction
* const filter = (interaction) => interaction.customId === 'button' && interaction.user.id === 'someId'; * const filter = (interaction) => interaction.customId === 'button' && interaction.user.id === 'someId';
* channel.awaitMessageComponent({ filter, time: 15000 }) * channel.awaitMessageComponent({ filter, time: 15_000 })
* .then(interaction => console.log(`${interaction.customId} was clicked!`)) * .then(interaction => console.log(`${interaction.customId} was clicked!`))
* .catch(console.error); * .catch(console.error);
*/ */
@@ -297,7 +297,7 @@ class TextBasedChannel {
if (Array.isArray(messages) || messages instanceof Collection) { if (Array.isArray(messages) || messages instanceof Collection) {
let messageIds = messages instanceof Collection ? [...messages.keys()] : messages.map(m => m.id ?? m); let messageIds = messages instanceof Collection ? [...messages.keys()] : messages.map(m => m.id ?? m);
if (filterOld) { if (filterOld) {
messageIds = messageIds.filter(id => Date.now() - SnowflakeUtil.deconstruct(id).timestamp < 1209600000); messageIds = messageIds.filter(id => Date.now() - SnowflakeUtil.deconstruct(id).timestamp < 1_209_600_000);
} }
if (messageIds.length === 0) return new Collection(); if (messageIds.length === 0) return new Collection();
if (messageIds.length === 1) { if (messageIds.length === 1) {

View File

@@ -79,7 +79,7 @@ class LimitedCollection extends Collection {
if (sweepFn === null) return; if (sweepFn === null) return;
if (typeof sweepFn !== 'function') throw new TypeError('SWEEP_FILTER_RETURN'); if (typeof sweepFn !== 'function') throw new TypeError('SWEEP_FILTER_RETURN');
this.sweep(sweepFn); this.sweep(sweepFn);
}, sweepInterval * 1000).unref() }, sweepInterval * 1_000).unref()
: null; : null;
} }
@@ -129,7 +129,7 @@ class LimitedCollection extends Collection {
} }
return () => { return () => {
if (lifetime <= 0) return null; if (lifetime <= 0) return null;
const lifetimeMs = lifetime * 1000; const lifetimeMs = lifetime * 1_000;
const now = Date.now(); const now = Date.now();
return (entry, key, coll) => { return (entry, key, coll) => {
if (excludeFromSweep(entry, key, coll)) { if (excludeFromSweep(entry, key, coll)) {

View File

@@ -115,8 +115,8 @@ class Options extends null {
messageSweepInterval: 0, messageSweepInterval: 0,
invalidRequestWarningInterval: 0, invalidRequestWarningInterval: 0,
partials: [], partials: [],
restWsBridgeTimeout: 5000, restWsBridgeTimeout: 5_000,
restRequestTimeout: 15000, restRequestTimeout: 15_000,
restGlobalRateLimit: 0, restGlobalRateLimit: 0,
retryLimit: 1, retryLimit: 1,
restTimeOffset: 500, restTimeOffset: 500,

View File

@@ -3,7 +3,7 @@
const Util = require('./Util'); const Util = require('./Util');
// Discord epoch (2015-01-01T00:00:00.000Z) // Discord epoch (2015-01-01T00:00:00.000Z)
const EPOCH = 1420070400000; const EPOCH = 1_420_070_400_000;
let INCREMENT = 0; let INCREMENT = 0;
/** /**

View File

@@ -69,7 +69,7 @@ class Util extends null {
* @param {SplitOptions} [options] Options controlling the behavior of the split * @param {SplitOptions} [options] Options controlling the behavior of the split
* @returns {string[]} * @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); text = Util.verifyString(text);
if (text.length <= maxLength) return [text]; if (text.length <= maxLength) return [text];
let splitText = [text]; let splitText = [text];
@@ -181,7 +181,7 @@ class Util extends null {
* @returns {string} * @returns {string}
*/ */
static escapeCodeBlock(text) { static escapeCodeBlock(text) {
return text.replace(/```/g, '\\`\\`\\`'); return text.replaceAll('```', '\\`\\`\\`');
} }
/** /**
@@ -243,7 +243,7 @@ class Util extends null {
* @returns {string} * @returns {string}
*/ */
static escapeStrikethrough(text) { static escapeStrikethrough(text) {
return text.replace(/~~/g, '\\~\\~'); return text.replaceAll('~~', '\\~\\~');
} }
/** /**
@@ -252,7 +252,7 @@ class Util extends null {
* @returns {string} * @returns {string}
*/ */
static escapeSpoiler(text) { 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 * @param {FetchRecommendedShardsOptions} [options] Options for fetching the recommended shard count
* @returns {Promise<number>} The recommended number of shards * @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'); if (!token) throw new DiscordError('TOKEN_MISSING');
const defaults = Options.createDefault(); const defaults = Options.createDefault();
const response = await fetch(`${defaults.http.api}/v${defaults.http.version}${Endpoints.botGateway}`, { const response = await fetch(`${defaults.http.api}/v${defaults.http.version}${Endpoints.botGateway}`, {
@@ -279,7 +279,7 @@ class Util extends null {
throw response; throw response;
} }
const { shards } = await response.json(); 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; bin = String(low & 1) + bin;
low = Math.floor(low / 2); low = Math.floor(low / 2);
if (high > 0) { if (high > 0) {
low += 5000000000 * (high % 2); low += 5_000_000_000 * (high % 2);
high = Math.floor(high / 2); high = Math.floor(high / 2);
} }
} }
@@ -577,7 +577,7 @@ class Util extends null {
* @returns {string} * @returns {string}
*/ */
static removeMentions(str) { static removeMentions(str) {
return str.replace(/@/g, '@\u200b'); return str.replaceAll('@', '@\u200b');
} }
/** /**
@@ -621,7 +621,7 @@ class Util extends null {
* @returns {string} * @returns {string}
*/ */
static cleanCodeBlockContent(text) { static cleanCodeBlockContent(text) {
return text.replace(/```/g, '`\u200b``'); return text.replaceAll('```', '`\u200b``');
} }
/** /**

View File

@@ -9,7 +9,14 @@ const { Client, Intents } = require('../src');
console.time('magic'); console.time('magic');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_MESSAGE_REACTIONS, Intents.FLAGS.GUILD_MEMBERS] }); const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
Intents.FLAGS.GUILD_MEMBERS,
],
});
client client
.login(token) .login(token)
@@ -17,17 +24,21 @@ client
.catch(console.error); .catch(console.error);
// Fetch all members in a new guild // Fetch all members in a new guild
client.on('guildCreate', guild => guild.members.fetch() client.on('guildCreate', guild =>
.catch(err => console.log(`Failed to fetch all members: ${err}\n${err.stack}`))); guild.members.fetch().catch(err => console.log(`Failed to fetch all members: ${err}\n${err.stack}`)),
);
// Fetch all members in a newly available guild // Fetch all members in a newly available guild
client.on('guildUpdate', (oldGuild, newGuild) => !oldGuild.available && newGuild.available ? guild.members.fetch() client.on('guildUpdate', (oldGuild, newGuild) =>
.catch(err => console.log(`Failed to fetch all members: ${err}\n${err.stack}`)) : Promise.resolve()); !oldGuild.available && newGuild.available
? guild.members.fetch().catch(err => console.log(`Failed to fetch all members: ${err}\n${err.stack}`))
: Promise.resolve(),
);
client.on('ready', async () => { client.on('ready', async () => {
// Fetch all members for initially available guilds // Fetch all members for initially available guilds
try { try {
const promises = client.guilds.cache.map(guild => guild.available ? guild.members.fetch() : Promise.resolve()); const promises = client.guilds.cache.map(guild => (guild.available ? guild.members.fetch() : Promise.resolve()));
await Promise.all(promises); await Promise.all(promises);
} catch (err) { } catch (err) {
console.log(`Failed to fetch all members before ready! ${err}\n${err.stack}`); console.log(`Failed to fetch all members before ready! ${err}\n${err.stack}`);
@@ -53,7 +64,7 @@ client.on('messageCreate', message => {
if (message.content === 'imma queue pls') { if (message.content === 'imma queue pls') {
let count = 0; let count = 0;
let ecount = 0; let ecount = 0;
for (let x = 0; x < 4000; x++) { for (let x = 0; x < 4_000; x++) {
message.channel message.channel
.send(`this is message ${x} of 3999`) .send(`this is message ${x} of 3999`)
.then(m => { .then(m => {
@@ -131,8 +142,7 @@ client.on('messageCreate', message => {
} }
if (message.content.startsWith('kick')) { if (message.content.startsWith('kick')) {
message.guild message.guild.members
.members
.resolve(message.mentions.users.first()) .resolve(message.mentions.users.first())
.kick() .kick()
.then(member => { .then(member => {
@@ -156,8 +166,7 @@ client.on('messageCreate', message => {
} }
if (message.content === 'makerole') { if (message.content === 'makerole') {
message.guild message.guild.roles
.roles
.create() .create()
.then(role => { .then(role => {
message.channel.send(`Made role ${role.name}`); message.channel.send(`Made role ${role.name}`);
@@ -172,10 +181,7 @@ function nameLoop(user) {
} }
function chanLoop(channel) { function chanLoop(channel) {
channel channel.setName(`${channel.name}a`).then(chanLoop).catch(console.error);
.setName(`${channel.name}a`)
.then(chanLoop)
.catch(console.error);
} }
client.on('messageCreate', msg => { client.on('messageCreate', msg => {
@@ -185,12 +191,7 @@ client.on('messageCreate', msg => {
if (msg.content.startsWith('#eval') && msg.author.id === '66564597481480192') { if (msg.content.startsWith('#eval') && msg.author.id === '66564597481480192') {
try { try {
const com = eval( const com = eval(msg.content.split(' ').slice(1).join(' '));
msg.content
.split(' ')
.slice(1)
.join(' '),
);
msg.channel.send(`\`\`\`\n${com}\`\`\``); msg.channel.send(`\`\`\`\n${com}\`\`\``);
} catch (e) { } catch (e) {
msg.channel.send(`\`\`\`\n${e}\`\`\``); msg.channel.send(`\`\`\`\n${e}\`\`\``);
@@ -203,21 +204,14 @@ let disp, con;
client.on('messageCreate', msg => { client.on('messageCreate', msg => {
if (msg.content.startsWith('/play')) { if (msg.content.startsWith('/play')) {
console.log('I am now going to play', msg.content); console.log('I am now going to play', msg.content);
const chan = msg.content const chan = msg.content.split(' ').slice(1).join(' ');
.split(' ')
.slice(1)
.join(' ');
const s = ytdl(chan, { filter: 'audioonly' }, { passes: 3 }); const s = ytdl(chan, { filter: 'audioonly' }, { passes: 3 });
s.on('error', e => console.log(`e w stream 1 ${e}`)); s.on('error', e => console.log(`e w stream 1 ${e}`));
con.play(s); con.play(s);
} }
if (msg.content.startsWith('/join')) { if (msg.content.startsWith('/join')) {
const chan = msg.content const chan = msg.content.split(' ').slice(1).join(' ');
.split(' ') msg.channel.guild.channels.cache
.slice(1)
.join(' ');
msg.channel.guild.channels
.cache
.get(chan) .get(chan)
.join() .join()
.then(conn => { .then(conn => {

View File

@@ -97,7 +97,7 @@ client.on('messageCreate', async message => {
for (const [i, test] of tests.entries()) { for (const [i, test] of tests.entries()) {
await message.channel.send(`**#${i}**\n\`\`\`js\n${test.toString()}\`\`\``); await message.channel.send(`**#${i}**\n\`\`\`js\n${test.toString()}\`\`\``);
await test(message).catch(e => message.channel.send(`Error!\n\`\`\`\n${e}\`\`\``)); await test(message).catch(e => message.channel.send(`Error!\n\`\`\`\n${e}\`\`\``));
await wait(1000); await wait(1_000);
} }
/* eslint-enable no-await-in-loop */ /* eslint-enable no-await-in-loop */
} else if (match) { } else if (match) {

View File

@@ -28,7 +28,7 @@ client.on('ready', () => {
setTimeout(() => { setTimeout(() => {
console.log('kek dying'); console.log('kek dying');
client.destroy(); client.destroy();
}, 5000); }, 5_000);
} }
}); });

View File

@@ -107,7 +107,7 @@ client.on('messageCreate', async message => {
for (const [i, test] of tests.entries()) { for (const [i, test] of tests.entries()) {
await message.channel.send(`**#${i}-Hook: ${type}**\n\`\`\`js\n${test.toString()}\`\`\``); await message.channel.send(`**#${i}-Hook: ${type}**\n\`\`\`js\n${test.toString()}\`\`\``);
await test(message, hook).catch(e => message.channel.send(`Error!\n\`\`\`\n${e}\`\`\``)); await test(message, hook).catch(e => message.channel.send(`Error!\n\`\`\`\n${e}\`\`\``));
await wait(1000); await wait(1_000);
} }
} }
/* eslint-enable no-await-in-loop */ /* eslint-enable no-await-in-loop */