mirror of
https://github.com/danbulant/discord.js
synced 2026-05-27 14:02:02 +00:00
fix: Client#sweepMessages should throw an INVALID_TYPE error (#3828)
* fix(Client): sweepMessages shouldn't shrow an invalid client option error * style: trailing commas
This commit is contained in:
parent
52c0a4067b
commit
02807347e7
1 changed files with 4 additions and 4 deletions
|
|
@ -64,7 +64,7 @@ class Client extends BaseClient {
|
|||
|
||||
if (Array.isArray(this.options.shards)) {
|
||||
this.options.shards = [...new Set(
|
||||
this.options.shards.filter(item => !isNaN(item) && item >= 0 && item < Infinity && item === (item | 0))
|
||||
this.options.shards.filter(item => !isNaN(item) && item >= 0 && item < Infinity && item === (item | 0)),
|
||||
)];
|
||||
}
|
||||
|
||||
|
|
@ -199,7 +199,7 @@ class Client extends BaseClient {
|
|||
if (!token || typeof token !== 'string') throw new Error('TOKEN_INVALID');
|
||||
this.token = token = token.replace(/^(Bot|Bearer)\s*/i, '');
|
||||
this.emit(Events.DEBUG,
|
||||
`Provided token: ${token.split('.').map((val, i) => i > 1 ? val.replace(/./g, '*') : val).join('.')}`
|
||||
`Provided token: ${token.split('.').map((val, i) => i > 1 ? val.replace(/./g, '*') : val).join('.')}`,
|
||||
);
|
||||
|
||||
if (this.options.presence) {
|
||||
|
|
@ -286,7 +286,7 @@ class Client extends BaseClient {
|
|||
*/
|
||||
sweepMessages(lifetime = this.options.messageCacheLifetime) {
|
||||
if (typeof lifetime !== 'number' || isNaN(lifetime)) {
|
||||
throw new TypeError('CLIENT_INVALID_OPTION', 'Lifetime', 'a number');
|
||||
throw new TypeError('INVALID_TYPE', 'lifetime', 'number');
|
||||
}
|
||||
if (lifetime <= 0) {
|
||||
this.emit(Events.DEBUG, 'Didn\'t sweep messages - lifetime is unlimited');
|
||||
|
|
@ -303,7 +303,7 @@ class Client extends BaseClient {
|
|||
channels++;
|
||||
|
||||
messages += channel.messages.cache.sweep(
|
||||
message => now - (message.editedTimestamp || message.createdTimestamp) > lifetimeMs
|
||||
message => now - (message.editedTimestamp || message.createdTimestamp) > lifetimeMs,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue