mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 11:33:30 +01: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:
@@ -64,7 +64,7 @@ class Client extends BaseClient {
|
|||||||
|
|
||||||
if (Array.isArray(this.options.shards)) {
|
if (Array.isArray(this.options.shards)) {
|
||||||
this.options.shards = [...new Set(
|
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');
|
if (!token || typeof token !== 'string') throw new Error('TOKEN_INVALID');
|
||||||
this.token = token = token.replace(/^(Bot|Bearer)\s*/i, '');
|
this.token = token = token.replace(/^(Bot|Bearer)\s*/i, '');
|
||||||
this.emit(Events.DEBUG,
|
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) {
|
if (this.options.presence) {
|
||||||
@@ -286,7 +286,7 @@ class Client extends BaseClient {
|
|||||||
*/
|
*/
|
||||||
sweepMessages(lifetime = this.options.messageCacheLifetime) {
|
sweepMessages(lifetime = this.options.messageCacheLifetime) {
|
||||||
if (typeof lifetime !== 'number' || isNaN(lifetime)) {
|
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) {
|
if (lifetime <= 0) {
|
||||||
this.emit(Events.DEBUG, 'Didn\'t sweep messages - lifetime is unlimited');
|
this.emit(Events.DEBUG, 'Didn\'t sweep messages - lifetime is unlimited');
|
||||||
@@ -303,7 +303,7 @@ class Client extends BaseClient {
|
|||||||
channels++;
|
channels++;
|
||||||
|
|
||||||
messages += channel.messages.cache.sweep(
|
messages += channel.messages.cache.sweep(
|
||||||
message => now - (message.editedTimestamp || message.createdTimestamp) > lifetimeMs
|
message => now - (message.editedTimestamp || message.createdTimestamp) > lifetimeMs,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user