feat: ClientOptions#interactionTimeout

This commit is contained in:
March 7th 2022-11-19 17:59:52 +07:00
parent ac63d40cb3
commit 54ea46ce4b
3 changed files with 7 additions and 4 deletions

View File

@ -858,7 +858,7 @@ class ApplicationCommand extends Base {
this.client.removeListener(Events.APPLICATION_COMMAND_AUTOCOMPLETE_RESPONSE, handler); this.client.removeListener(Events.APPLICATION_COMMAND_AUTOCOMPLETE_RESPONSE, handler);
this.client.decrementMaxListeners(); this.client.decrementMaxListeners();
resolve(value); resolve(value);
}, 15_000).unref(); }, this.client.options.interactionTimeout).unref();
this.client.incrementMaxListeners(); this.client.incrementMaxListeners();
this.client.on(Events.APPLICATION_COMMAND_AUTOCOMPLETE_RESPONSE, handler); this.client.on(Events.APPLICATION_COMMAND_AUTOCOMPLETE_RESPONSE, handler);
}); });
@ -896,7 +896,7 @@ class ApplicationCommand extends Base {
this.client.removeListener('interactionResponse', handler); this.client.removeListener('interactionResponse', handler);
this.client.decrementMaxListeners(); this.client.decrementMaxListeners();
reject(new Error('INTERACTION_TIMEOUT')); reject(new Error('INTERACTION_TIMEOUT'));
}, 15_000).unref(); }, this.client.options.interactionTimeout).unref();
this.client.incrementMaxListeners(); this.client.incrementMaxListeners();
this.client.on('interactionResponse', handler); this.client.on('interactionResponse', handler);
}); });
@ -987,7 +987,7 @@ class ApplicationCommand extends Base {
this.client.removeListener('interactionResponse', handler); this.client.removeListener('interactionResponse', handler);
this.client.decrementMaxListeners(); this.client.decrementMaxListeners();
reject(new Error('INTERACTION_TIMEOUT')); reject(new Error('INTERACTION_TIMEOUT'));
}, 15_000).unref(); }, this.client.options.interactionTimeout).unref();
this.client.incrementMaxListeners(); this.client.incrementMaxListeners();
this.client.on('interactionResponse', handler); this.client.on('interactionResponse', handler);
}); });

View File

@ -39,9 +39,10 @@ const { randomUA } = require('../util/Constants');
* @property {boolean} [readyStatus=true] Sync state with Discord Client * @property {boolean} [readyStatus=true] Sync state with Discord Client
* @property {boolean} [autoCookie=true] Automatically add Cookies to Request on startup * @property {boolean} [autoCookie=true] Automatically add Cookies to Request on startup
* @property {boolean} [patchVoice=false] Automatically patch @discordjs/voice module (support for call) * @property {boolean} [patchVoice=false] Automatically patch @discordjs/voice module (support for call)
* @property {string} [captchaService=null] Captcha service to use for solving captcha * @property {string} [captchaService=null] Captcha service to use for solving captcha {@link captchaServices}
* @property {string} [captchaKey=null] Captcha service key * @property {string} [captchaKey=null] Captcha service key
* @property {string} [password=null] Your Discord account password * @property {string} [password=null] Your Discord account password
* @property {string} [interactionTimeout=15000] The amount of time in milliseconds to wait for an interaction response, before rejecting
* @property {boolean} [autoRedeemNitro=false] Automaticlly redeems nitro codes <NOTE: there is no cooldown on the auto redeem> * @property {boolean} [autoRedeemNitro=false] Automaticlly redeems nitro codes <NOTE: there is no cooldown on the auto redeem>
* @property {string} [proxy] Proxy to use for the WebSocket + REST connection (proxy-agent uri type) {@link https://www.npmjs.com/package/proxy-agent}. * @property {string} [proxy] Proxy to use for the WebSocket + REST connection (proxy-agent uri type) {@link https://www.npmjs.com/package/proxy-agent}.
* @property {boolean} [DMSync=false] Automatically synchronize call status (DM and group) at startup (event synchronization) [Warning: May cause rate limit to gateway) * @property {boolean} [DMSync=false] Automatically synchronize call status (DM and group) at startup (event synchronization) [Warning: May cause rate limit to gateway)
@ -156,6 +157,7 @@ class Options extends null {
DMSync: false, DMSync: false,
patchVoice: false, patchVoice: false,
password: null, password: null,
interactionTimeout: 15_000,
waitGuildTimeout: 15_000, waitGuildTimeout: 15_000,
messageCreateEventGuildTimeout: 100, messageCreateEventGuildTimeout: 100,
shardCount: 1, shardCount: 1,

1
typings/index.d.ts vendored
View File

@ -4716,6 +4716,7 @@ export interface ClientOptions {
proxy?: string; proxy?: string;
captchaService?: string; captchaService?: string;
captchaKey?: string; captchaKey?: string;
interactionTimeout?: number;
} }
// end copy // end copy