diff --git a/src/commands/check-limit.ts b/src/commands/check-limit.ts index 870874f..4104c0f 100644 --- a/src/commands/check-limit.ts +++ b/src/commands/check-limit.ts @@ -38,7 +38,7 @@ export default class MyLimit extends Command implements Command { const nthUseInLimitTimestamp = await nthUseInLimitTimestampPromise; if (userLimit === false || nthUseInLimitTimestamp === false) { - await interaction.reply({ + interaction.reply({ embeds: [{ author: { name: interaction.user.username, icon_url: interaction.user.displayAvatarURL({ size: 128 }) }, description: "User is a VIP, so there is no limit", @@ -48,7 +48,7 @@ export default class MyLimit extends Command implements Command { return; } - await interaction.reply({ + interaction.reply({ embeds: [{ author: { name: interaction.user.username, icon_url: interaction.user.displayAvatarURL({ size: 128 }) }, fields: [ diff --git a/src/execution.ts b/src/execution.ts index 7378659..0560417 100644 --- a/src/execution.ts +++ b/src/execution.ts @@ -157,7 +157,7 @@ export async function queueRequest(request: apiRequest) { "You've used up your message limit for today,\n" + `${userLimit.limit} requests in last 24 hours`, }] - }).catch(() => {/* FIXME: What should the bot do in this case to inform of limit reached?*/}); + }).catch(() => {/* GRACEFAIL: */}); } else if (request.isRepliable()) { request.reply({ @@ -175,7 +175,7 @@ export async function queueRequest(request: apiRequest) { const shouldStart = messagesForChannel.length === 0; messagesForChannel.push(request as request); if (shouldStart) - void executeFromQueue(request.channelId); + executeFromQueue(request.channelId); } /** @@ -234,10 +234,10 @@ async function executeFromQueue(channel: string) { messages.forEach(m => { Moderation.checkMessage(m); }); if (message instanceof DiscordApi.Message) { - await message.channel.sendTyping(); + message.channel.sendTyping(); } else if (message.isRepliable()) { - await message.deferReply(); + message.deferReply(); } OpenAImessages = toOpenAIMessages(messages); @@ -270,7 +270,7 @@ async function executeFromQueue(channel: string) { const answerContent = answer.data.choices[0].message?.content; if (answerContent === undefined || answerContent === "") { - if (message instanceof DiscordApi.Message) message.react("😶").catch(() => {/* GRACEFAIL: It's okay if the bot won't reply */}); + if (message instanceof DiscordApi.Message) message.react("😶").catch(/*it's okay*/); } else { const answerMessagesContent :string[] = [""]; @@ -286,7 +286,8 @@ async function executeFromQueue(channel: string) { for (const i of answerMessagesContent) { const response = requestReply(message, {content: i}, {allowedMentions: { repliedUser: false }}); - await response.then(rval => Moderation.checkMessage(rval)); + response.then(rval => Moderation.checkMessage(rval)); + await response; } } } catch (e) { @@ -304,7 +305,7 @@ async function executeFromQueue(channel: string) { } else errorText = ""; - await requestReply( + requestReply( message, { embeds: [{ @@ -321,5 +322,5 @@ async function executeFromQueue(channel: string) { if (channelQueue.length === 0) channelsRunning.delete(channel); else - return executeFromQueue(channel); + executeFromQueue(channel); } diff --git a/src/index.ts b/src/index.ts index b96a479..bc732ba 100644 --- a/src/index.ts +++ b/src/index.ts @@ -31,7 +31,7 @@ discord.on("messageCreate", message => { if (message.author.bot) return; if (!message.mentions.has(message.client.user)) return; - return queueRequest(message); + queueRequest(message); }); -if (require.main === module) void discord.login(config.tokens.Discord); +if (require.main === module) discord.login(config.tokens.Discord); diff --git a/src/interactionManager.ts b/src/interactionManager.ts index ff1614b..df7895b 100644 --- a/src/interactionManager.ts +++ b/src/interactionManager.ts @@ -30,26 +30,14 @@ export default class CommandManager { ) { const foundCommand = this.commands.find((command) => command.name === interaction.commandName ); if (!foundCommand) throw new Error(`Unknown command received (${interaction.commandName}). Did you forgot to push updated commands?`); - foundCommand.execute(interaction).catch(e => { - interaction.reply({ - embeds: [{ - color: 0xff0000, - description: `Failed to perform interaction:\n\`${e}\``, - }] - }).catch(() => {/* NOTE: We're still logging the issue that happened to the console */}); - console.error(`Failed to perform interaction: ${interaction.commandName}`); - console.error(e); - }); + foundCommand.execute(interaction); return; } if (interaction.isAutocomplete()) { const foundCommand = this.commands.find((command) => command.name === interaction.commandName ); if (!foundCommand) throw new Error(`Unknown command received (${interaction.commandName}). Did you forgot to push updated commands?`); if (!foundCommand.autocomplete) return; - foundCommand.autocomplete(interaction).catch(e => { - console.error(`Failed to perform autocomplete interaction: ${interaction.commandName}`); - console.error(e); - }); + foundCommand.autocomplete(interaction); return; } }