generated from nhcarrigan/template
a36d706eed
## Summary - **feat**: Add `/remind` owner-only command — sends a meeting waiting room notification to a specified user in `#general` - **fix**: Prevent duplicate DM notifications when a message matches both `respondToMention` and `notifyNameMention` patterns - **feat**: Port `/alt-text` and `/query` commands from Cordelia — owner-only, AI-powered, using Amari's personality - **feat**: Add `/research` command — owner-only, web-search-backed query returning results as a markdown file attachment - **fix**: Suppress non-critical RetroAchievements fetch errors (job retries every 10 minutes) Closes #19, #20, #21, #22 Also resolves #2 (unhandled HTTP rejections from RA API) Reviewed-on: #23 Co-authored-by: Hikari <hikari@nhcarrigan.com> Co-committed-by: Hikari <hikari@nhcarrigan.com>
58 lines
1.8 KiB
TypeScript
58 lines
1.8 KiB
TypeScript
/**
|
|
* @copyright NHCarrigan
|
|
* @license Naomi's Public License
|
|
* @author Naomi Carrigan
|
|
*/
|
|
|
|
import { MessageFlags, type ChatInputCommandInteraction } from "discord.js";
|
|
import { ids } from "../config/ids.js";
|
|
import { logger } from "../utils/logger.js";
|
|
import { makeAiRequest } from "../utils/makeAiRequest.js";
|
|
import type { Amari } from "../interfaces/amari.js";
|
|
|
|
const fallbackResponse = "I'm sorry, I don't have an answer for that."
|
|
+ " Please try again later.";
|
|
|
|
/**
|
|
* Accepts an arbitrary question and sends it to Claude to be answered.
|
|
* @param _amari - The Amari instance (unused but kept for handler consistency).
|
|
* @param interaction - The Discord slash command interaction.
|
|
*/
|
|
export const query = async(
|
|
_amari: Amari,
|
|
interaction: ChatInputCommandInteraction,
|
|
): Promise<void> => {
|
|
if (interaction.user.id !== ids.users.naomi) {
|
|
await interaction.reply({
|
|
content: "This command is restricted to Naomi.",
|
|
flags: [ MessageFlags.Ephemeral ],
|
|
});
|
|
return;
|
|
}
|
|
|
|
const prompt = interaction.options.getString("prompt", true);
|
|
|
|
await interaction.deferReply({ flags: [ MessageFlags.Ephemeral ] });
|
|
|
|
try {
|
|
const response = await makeAiRequest({
|
|
maxTokens: 2000,
|
|
systemPrompt: "Your role in this conversation is to answer the user's"
|
|
+ " question to the best of your abilities. When possible, include"
|
|
+ " links to relevant sources.",
|
|
userMessage: prompt,
|
|
});
|
|
|
|
await interaction.editReply({
|
|
content: response ?? fallbackResponse,
|
|
});
|
|
} catch (error) {
|
|
await logger.error("query command", error instanceof Error
|
|
? error
|
|
: new Error(String(error)));
|
|
await interaction.editReply({
|
|
content: "Something went wrong whilst processing your question.",
|
|
});
|
|
}
|
|
};
|