defer replies to all commands to avoid timeouts

This commit is contained in:
Erik 2022-07-11 14:43:59 +03:00
parent 7643256df7
commit 7f575ce617
Signed by untrusted user: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB
3 changed files with 6 additions and 3 deletions

View File

@ -53,7 +53,7 @@ class PollCommand extends SlashCommand {
if (subcommand.name === 'create') {
await invoker.deferReply();
// await invoker.deferReply();
const questions = [];
const _channel = channel?.value || invoker.channel;

View File

@ -76,13 +76,14 @@ class CommandHandler extends Observer {
emoji: 'failure', ephemeral: true
});
await invoker.deferReply();
const inhibitors = await this._handleInhibitors(invoker);
if(inhibitors.length) return this._generateError(invoker, { type: 'inhibitor', ...inhibitors[0] });
const response = await this._parseInteraction(interaction, command);
if (await this._parseResponse(invoker, response)) return;
try {
try { // Temp logging
await this._executeCommand(invoker, response.options);
} catch (err) {
this.logger.error(`_executeCommand errored:\nCommand: ${invoker.command.name}\nOptions:\n${Object.keys(response.options).map((key) => `[${key}: ${response.options[key]._rawValue}]`).join('\n')}\n${err.stack}`);
@ -130,6 +131,8 @@ class CommandHandler extends Observer {
}
async _executeCommand(invoker, options) {
// TODO defer all replies -- need to go through all commands to ensure they're not deferrign them to avoid errors
// Why? Occasionally some interacitons don't complete in time due to taking longer than normal to reach the bot -- unsure if deferring all replies will fix it
let response = null;
const now = Date.now();

View File

@ -97,7 +97,7 @@ class SettingsCommand extends SlashCommand {
});
}
await invoker.deferReply();
// await invoker.deferReply();
const settings = await guild.settings();
if (!Object.keys(opts).length && this.subcommand(subcommand.name).options.length) return this._showSetting(invoker, setting);