Compare commits

..

No commits in common. "5a116b053178a7edc16f9bc8a18f1cd9786097fe" and "72257395271d59dea87bb93298ee786c0e1b76c4" have entirely different histories.

4 changed files with 15 additions and 26 deletions

View file

@ -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: [

View file

@ -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);
}

View file

@ -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);

View file

@ -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;
}
}