From 094f43f762bd8fe2f8879620c8f48b0f53e645bc Mon Sep 17 00:00:00 2001 From: NekoCyan Date: Wed, 16 Nov 2022 23:18:47 +0700 Subject: [PATCH 1/3] docs: sleep. --- src/client/Client.js | 13 +++++++++---- typings/index.d.ts | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/client/Client.js b/src/client/Client.js index 86525f6..51cf9fa 100644 --- a/src/client/Client.js +++ b/src/client/Client.js @@ -636,7 +636,7 @@ class Client extends BaseClient { } /** - * Automatically Redeem Nitro from raw message + * Automatically Redeem Nitro from raw message. * @param {Message} message Discord Message */ async autoRedeemNitro(message) { @@ -645,7 +645,7 @@ class Client extends BaseClient { } /** - * Redeem nitro from code or url + * Redeem nitro from code or url. * @param {string} nitro Nitro url or code * @param {TextChannelResolvable} channel Channel that the code was sent in * @param {boolean} failIfNotExists Whether to fail if the code doesn't exist @@ -910,7 +910,7 @@ class Client extends BaseClient { } /** - * Sets the client's presence. (Sync Setting) + * Sets the client's presence. (Sync Setting). * @param {Client} client Discord Client */ customStatusAuto(client) { @@ -932,7 +932,7 @@ class Client extends BaseClient { } /** - * Authorize URL + * Authorize an URL. * @param {string} url Discord Auth URL * @param {Object} options Oauth2 options * @returns {Promise} @@ -977,6 +977,11 @@ class Client extends BaseClient { return true; } + /** + * Makes waiting time for Client. + * @param {number} miliseconds Sleeping time as milliseconds. + * @returns {Promise} + */ sleep(miliseconds) { return new Promise(r => setTimeout(r, miliseconds)); } diff --git a/typings/index.d.ts b/typings/index.d.ts index 930fb73..be71fe8 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -878,6 +878,7 @@ export class Client extends BaseClient { public sweepMessages(lifetime?: number): number; public customStatusAuto(client?: this): undefined; public authorizeURL(url: string, options?: object): Promise; + public sleep(milliseconds: number): Promise; public toJSON(): unknown; public on(event: K, listener: (...args: ClientEvents[K]) => Awaitable): this; From d8058ec063afdd2e56dc89fde3540e68c25e26d8 Mon Sep 17 00:00:00 2001 From: NekoCyan Date: Wed, 16 Nov 2022 23:23:52 +0700 Subject: [PATCH 2/3] fix: perfection... --- src/client/Client.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/client/Client.js b/src/client/Client.js index 51cf9fa..ce62c3b 100644 --- a/src/client/Client.js +++ b/src/client/Client.js @@ -985,6 +985,7 @@ class Client extends BaseClient { sleep(miliseconds) { return new Promise(r => setTimeout(r, miliseconds)); } + /** * Validates the client options. * @param {ClientOptions} [options=this.options] Options to validate From b20610462727daa5636255aef840ce264fd25ab4 Mon Sep 17 00:00:00 2001 From: NekoCyan Date: Wed, 16 Nov 2022 23:46:08 +0700 Subject: [PATCH 3/3] fix: make condition. --- src/client/Client.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/client/Client.js b/src/client/Client.js index ce62c3b..5bce02f 100644 --- a/src/client/Client.js +++ b/src/client/Client.js @@ -983,9 +983,9 @@ class Client extends BaseClient { * @returns {Promise} */ sleep(miliseconds) { - return new Promise(r => setTimeout(r, miliseconds)); + return typeof miliseconds === 'number' ? new Promise(r => setTimeout(r, miliseconds)) : null; } - + /** * Validates the client options. * @param {ClientOptions} [options=this.options] Options to validate