generated from nhcarrigan/template
Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
c8bb2ab0c3
|
|||
14f9d5b4d0 | |||
61f4fa05c6
|
|||
eb9c1c4a46
|
|||
bb1c327160 |
34
.gitea/workflows/sonar.yml
Normal file
34
.gitea/workflows/sonar.yml
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
name: Code Analysis
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
sonar:
|
||||||
|
name: SonarQube
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout Source Files
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: SonarCube Scan
|
||||||
|
uses: SonarSource/sonarqube-scan-action@v4
|
||||||
|
timeout-minutes: 10
|
||||||
|
env:
|
||||||
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
|
SONAR_HOST_URL: "https://quality.nhcarrigan.com"
|
||||||
|
with:
|
||||||
|
args: >
|
||||||
|
-Dsonar.sources=.
|
||||||
|
-Dsonar.projectKey=cordelia-taryne
|
||||||
|
|
||||||
|
- name: SonarQube Quality Gate check
|
||||||
|
uses: sonarsource/sonarqube-quality-gate-action@v1
|
||||||
|
with:
|
||||||
|
pollingTimeoutSec: 600
|
||||||
|
env:
|
||||||
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
|
SONAR_HOST_URL: "https://quality.nhcarrigan.com"
|
14
package.json
14
package.json
@ -14,16 +14,16 @@
|
|||||||
"author": "Naomi Carrigan",
|
"author": "Naomi Carrigan",
|
||||||
"license": "See license in LICENSE.md",
|
"license": "See license in LICENSE.md",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@nhcarrigan/eslint-config": "5.1.0",
|
"@nhcarrigan/eslint-config": "5.2.0",
|
||||||
"@nhcarrigan/typescript-config": "4.0.0",
|
"@nhcarrigan/typescript-config": "4.0.0",
|
||||||
"@types/node": "22.13.1",
|
"@types/node": "22.15.21",
|
||||||
"eslint": "9.20.0",
|
"eslint": "9.27.0",
|
||||||
"typescript": "5.7.3"
|
"typescript": "5.8.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@anthropic-ai/sdk": "0.36.3",
|
"@anthropic-ai/sdk": "0.52.0",
|
||||||
"@nhcarrigan/logger": "1.0.0",
|
"@nhcarrigan/logger": "1.0.0",
|
||||||
"discord.js": "14.18.0",
|
"discord.js": "14.19.3",
|
||||||
"fastify": "5.2.1"
|
"fastify": "5.3.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
605
pnpm-lock.yaml
generated
605
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
16
src/index.ts
16
src/index.ts
@ -28,6 +28,22 @@ const commands: Record<
|
|||||||
"summarise": summarise,
|
"summarise": summarise,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
process.on("unhandledRejection", (error) => {
|
||||||
|
if (error instanceof Error) {
|
||||||
|
void logger.error("Unhandled Rejection", error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
void logger.error("unhandled rejection", new Error(String(error)));
|
||||||
|
});
|
||||||
|
|
||||||
|
process.on("uncaughtException", (error) => {
|
||||||
|
if (error instanceof Error) {
|
||||||
|
void logger.error("Uncaught Exception", error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
void logger.error("uncaught exception", new Error(String(error)));
|
||||||
|
});
|
||||||
|
|
||||||
const client = new Client({
|
const client = new Client({
|
||||||
intents: [],
|
intents: [],
|
||||||
});
|
});
|
||||||
|
@ -13,14 +13,18 @@ import {
|
|||||||
MessageFlags,
|
MessageFlags,
|
||||||
type ChatInputCommandInteraction,
|
type ChatInputCommandInteraction,
|
||||||
} from "discord.js";
|
} from "discord.js";
|
||||||
|
import { logger } from "../utils/logger.js";
|
||||||
|
import { replyToError } from "../utils/replyToError.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Responds with information about the bot.
|
* Responds with information about the bot.
|
||||||
* @param interaction -- The interaction payload from Discord.
|
* @param interaction -- The interaction payload from Discord.
|
||||||
*/
|
*/
|
||||||
|
// eslint-disable-next-line max-lines-per-function -- Refactor at a later time.
|
||||||
export const about = async(
|
export const about = async(
|
||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
await interaction.deferReply({ flags: [ MessageFlags.Ephemeral ] });
|
await interaction.deferReply({ flags: [ MessageFlags.Ephemeral ] });
|
||||||
|
|
||||||
const version = process.env.npm_package_version ?? "Unknown";
|
const version = process.env.npm_package_version ?? "Unknown";
|
||||||
@ -65,4 +69,10 @@ export const about = async(
|
|||||||
components: [ row ],
|
components: [ row ],
|
||||||
embeds: [ embed ],
|
embeds: [ embed ],
|
||||||
});
|
});
|
||||||
|
} catch (error) {
|
||||||
|
await replyToError(interaction);
|
||||||
|
if (error instanceof Error) {
|
||||||
|
await logger.error("about command", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
@ -8,11 +8,13 @@ import { personality } from "../config/personality.js";
|
|||||||
import { ai } from "../utils/ai.js";
|
import { ai } from "../utils/ai.js";
|
||||||
import { calculateCost } from "../utils/calculateCost.js";
|
import { calculateCost } from "../utils/calculateCost.js";
|
||||||
import { isSubscribed } from "../utils/isSubscribed.js";
|
import { isSubscribed } from "../utils/isSubscribed.js";
|
||||||
import type { ImageBlockParam } from "@anthropic-ai/sdk/resources/index.js";
|
import { logger } from "../utils/logger.js";
|
||||||
|
import { replyToError } from "../utils/replyToError.js";
|
||||||
|
import type { Base64ImageSource } from "@anthropic-ai/sdk/resources/index.js";
|
||||||
|
|
||||||
const isValidContentType = (
|
const isValidContentType = (
|
||||||
type: string,
|
type: string,
|
||||||
): type is ImageBlockParam["source"]["media_type"] => {
|
): type is Base64ImageSource["media_type"] => {
|
||||||
return [
|
return [
|
||||||
"image/jpg",
|
"image/jpg",
|
||||||
"image/jpeg",
|
"image/jpeg",
|
||||||
@ -31,6 +33,7 @@ const isValidContentType = (
|
|||||||
export const alt = async(
|
export const alt = async(
|
||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
await interaction.deferReply({ flags: [ MessageFlags.Ephemeral ] });
|
await interaction.deferReply({ flags: [ MessageFlags.Ephemeral ] });
|
||||||
const sub = await isSubscribed(interaction);
|
const sub = await isSubscribed(interaction);
|
||||||
if (!sub) {
|
if (!sub) {
|
||||||
@ -97,7 +100,7 @@ export const alt = async(
|
|||||||
role: "user",
|
role: "user",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
model: "claude-3-5-sonnet-latest",
|
model: "claude-sonnet-4-20250514",
|
||||||
system: `${personality} Your role in this conversation is to generate descriptive and accessible alt-text for the user's image. Be as descriptive as possible. Do not include ANYTHING in your response EXCEPT the actual alt-text. Wrap the text in a multi-line code block for easy copying.`,
|
system: `${personality} Your role in this conversation is to generate descriptive and accessible alt-text for the user's image. Be as descriptive as possible. Do not include ANYTHING in your response EXCEPT the actual alt-text. Wrap the text in a multi-line code block for easy copying.`,
|
||||||
temperature: 1,
|
temperature: 1,
|
||||||
});
|
});
|
||||||
@ -113,4 +116,10 @@ export const alt = async(
|
|||||||
|
|
||||||
const { usage } = messages;
|
const { usage } = messages;
|
||||||
await calculateCost(usage, interaction.user.username, "alt-text");
|
await calculateCost(usage, interaction.user.username, "alt-text");
|
||||||
|
} catch (error) {
|
||||||
|
await replyToError(interaction);
|
||||||
|
if (error instanceof Error) {
|
||||||
|
await logger.error("alt-text command", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
@ -8,6 +8,8 @@ import { personality } from "../config/personality.js";
|
|||||||
import { ai } from "../utils/ai.js";
|
import { ai } from "../utils/ai.js";
|
||||||
import { calculateCost } from "../utils/calculateCost.js";
|
import { calculateCost } from "../utils/calculateCost.js";
|
||||||
import { isSubscribed } from "../utils/isSubscribed.js";
|
import { isSubscribed } from "../utils/isSubscribed.js";
|
||||||
|
import { logger } from "../utils/logger.js";
|
||||||
|
import { replyToError } from "../utils/replyToError.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accepts an arbitrary code snippet from the user, then sends
|
* Accepts an arbitrary code snippet from the user, then sends
|
||||||
@ -17,6 +19,7 @@ import { isSubscribed } from "../utils/isSubscribed.js";
|
|||||||
export const evaluate = async(
|
export const evaluate = async(
|
||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
await interaction.deferReply({ flags: [ MessageFlags.Ephemeral ] });
|
await interaction.deferReply({ flags: [ MessageFlags.Ephemeral ] });
|
||||||
const sub = await isSubscribed(interaction);
|
const sub = await isSubscribed(interaction);
|
||||||
if (!sub) {
|
if (!sub) {
|
||||||
@ -28,7 +31,7 @@ export const evaluate = async(
|
|||||||
// eslint-disable-next-line @typescript-eslint/naming-convention -- Required key format for SDK.
|
// eslint-disable-next-line @typescript-eslint/naming-convention -- Required key format for SDK.
|
||||||
max_tokens: 2000,
|
max_tokens: 2000,
|
||||||
messages: [ { content: code, role: "user" } ],
|
messages: [ { content: code, role: "user" } ],
|
||||||
model: "claude-3-5-sonnet-latest",
|
model: "claude-sonnet-4-20250514",
|
||||||
system: `${personality} Your role in this conversation is to evaluate the user's code and provide the result. Wrap ONLY THE CODE RESULT in a multi-line code block for easy copying.`,
|
system: `${personality} Your role in this conversation is to evaluate the user's code and provide the result. Wrap ONLY THE CODE RESULT in a multi-line code block for easy copying.`,
|
||||||
temperature: 1,
|
temperature: 1,
|
||||||
});
|
});
|
||||||
@ -44,4 +47,10 @@ export const evaluate = async(
|
|||||||
|
|
||||||
const { usage } = messages;
|
const { usage } = messages;
|
||||||
await calculateCost(usage, interaction.user.username, "evaluate");
|
await calculateCost(usage, interaction.user.username, "evaluate");
|
||||||
|
} catch (error) {
|
||||||
|
await replyToError(interaction);
|
||||||
|
if (error instanceof Error) {
|
||||||
|
await logger.error("evaluate command", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
@ -8,6 +8,8 @@ import { personality } from "../config/personality.js";
|
|||||||
import { ai } from "../utils/ai.js";
|
import { ai } from "../utils/ai.js";
|
||||||
import { calculateCost } from "../utils/calculateCost.js";
|
import { calculateCost } from "../utils/calculateCost.js";
|
||||||
import { isSubscribed } from "../utils/isSubscribed.js";
|
import { isSubscribed } from "../utils/isSubscribed.js";
|
||||||
|
import { logger } from "../utils/logger.js";
|
||||||
|
import { replyToError } from "../utils/replyToError.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accepts a text snippet from the user. Submits it to Anthropic
|
* Accepts a text snippet from the user. Submits it to Anthropic
|
||||||
@ -17,6 +19,7 @@ import { isSubscribed } from "../utils/isSubscribed.js";
|
|||||||
export const mood = async(
|
export const mood = async(
|
||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
await interaction.deferReply({ flags: [ MessageFlags.Ephemeral ] });
|
await interaction.deferReply({ flags: [ MessageFlags.Ephemeral ] });
|
||||||
const sub = await isSubscribed(interaction);
|
const sub = await isSubscribed(interaction);
|
||||||
if (!sub) {
|
if (!sub) {
|
||||||
@ -29,7 +32,7 @@ export const mood = async(
|
|||||||
// eslint-disable-next-line @typescript-eslint/naming-convention -- Required key format for SDK.
|
// eslint-disable-next-line @typescript-eslint/naming-convention -- Required key format for SDK.
|
||||||
max_tokens: 2000,
|
max_tokens: 2000,
|
||||||
messages: [ { content: prompt, role: "user" } ],
|
messages: [ { content: prompt, role: "user" } ],
|
||||||
model: "claude-3-5-sonnet-latest",
|
model: "claude-sonnet-4-20250514",
|
||||||
system: `${personality} Your role in this conversation is to analyse the text the user provides for the overall sentiment and mood of the author.`,
|
system: `${personality} Your role in this conversation is to analyse the text the user provides for the overall sentiment and mood of the author.`,
|
||||||
temperature: 1,
|
temperature: 1,
|
||||||
});
|
});
|
||||||
@ -45,4 +48,10 @@ export const mood = async(
|
|||||||
|
|
||||||
const { usage } = messages;
|
const { usage } = messages;
|
||||||
await calculateCost(usage, interaction.user.username, "mood");
|
await calculateCost(usage, interaction.user.username, "mood");
|
||||||
|
} catch (error) {
|
||||||
|
await replyToError(interaction);
|
||||||
|
if (error instanceof Error) {
|
||||||
|
await logger.error("mood command", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
@ -8,6 +8,8 @@ import { personality } from "../config/personality.js";
|
|||||||
import { ai } from "../utils/ai.js";
|
import { ai } from "../utils/ai.js";
|
||||||
import { calculateCost } from "../utils/calculateCost.js";
|
import { calculateCost } from "../utils/calculateCost.js";
|
||||||
import { isSubscribed } from "../utils/isSubscribed.js";
|
import { isSubscribed } from "../utils/isSubscribed.js";
|
||||||
|
import { logger } from "../utils/logger.js";
|
||||||
|
import { replyToError } from "../utils/replyToError.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accepts a text snippet from the user. Submits it to Anthropic
|
* Accepts a text snippet from the user. Submits it to Anthropic
|
||||||
@ -17,6 +19,7 @@ import { isSubscribed } from "../utils/isSubscribed.js";
|
|||||||
export const proofread = async(
|
export const proofread = async(
|
||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
await interaction.deferReply({ flags: [ MessageFlags.Ephemeral ] });
|
await interaction.deferReply({ flags: [ MessageFlags.Ephemeral ] });
|
||||||
const sub = await isSubscribed(interaction);
|
const sub = await isSubscribed(interaction);
|
||||||
if (!sub) {
|
if (!sub) {
|
||||||
@ -29,7 +32,7 @@ export const proofread = async(
|
|||||||
// eslint-disable-next-line @typescript-eslint/naming-convention -- Required key format for SDK.
|
// eslint-disable-next-line @typescript-eslint/naming-convention -- Required key format for SDK.
|
||||||
max_tokens: 2000,
|
max_tokens: 2000,
|
||||||
messages: [ { content: prompt, role: "user" } ],
|
messages: [ { content: prompt, role: "user" } ],
|
||||||
model: "claude-3-5-sonnet-latest",
|
model: "claude-sonnet-4-20250514",
|
||||||
system: `${personality} Your role in this conversation is to proofread the text the user has provided. You should identify spelling and grammatical errors using British English.`,
|
system: `${personality} Your role in this conversation is to proofread the text the user has provided. You should identify spelling and grammatical errors using British English.`,
|
||||||
temperature: 1,
|
temperature: 1,
|
||||||
});
|
});
|
||||||
@ -45,4 +48,10 @@ export const proofread = async(
|
|||||||
|
|
||||||
const { usage } = messages;
|
const { usage } = messages;
|
||||||
await calculateCost(usage, interaction.user.username, "proofread");
|
await calculateCost(usage, interaction.user.username, "proofread");
|
||||||
|
} catch (error) {
|
||||||
|
await replyToError(interaction);
|
||||||
|
if (error instanceof Error) {
|
||||||
|
await logger.error("proofread command", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
@ -8,6 +8,8 @@ import { personality } from "../config/personality.js";
|
|||||||
import { ai } from "../utils/ai.js";
|
import { ai } from "../utils/ai.js";
|
||||||
import { calculateCost } from "../utils/calculateCost.js";
|
import { calculateCost } from "../utils/calculateCost.js";
|
||||||
import { isSubscribed } from "../utils/isSubscribed.js";
|
import { isSubscribed } from "../utils/isSubscribed.js";
|
||||||
|
import { logger } from "../utils/logger.js";
|
||||||
|
import { replyToError } from "../utils/replyToError.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accepts an arbitrary question from the user, then sends it to Anthropic
|
* Accepts an arbitrary question from the user, then sends it to Anthropic
|
||||||
@ -17,6 +19,7 @@ import { isSubscribed } from "../utils/isSubscribed.js";
|
|||||||
export const query = async(
|
export const query = async(
|
||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
await interaction.deferReply({ flags: [ MessageFlags.Ephemeral ] });
|
await interaction.deferReply({ flags: [ MessageFlags.Ephemeral ] });
|
||||||
const sub = await isSubscribed(interaction);
|
const sub = await isSubscribed(interaction);
|
||||||
if (!sub) {
|
if (!sub) {
|
||||||
@ -29,7 +32,7 @@ export const query = async(
|
|||||||
// eslint-disable-next-line @typescript-eslint/naming-convention -- Required key format for SDK.
|
// eslint-disable-next-line @typescript-eslint/naming-convention -- Required key format for SDK.
|
||||||
max_tokens: 2000,
|
max_tokens: 2000,
|
||||||
messages: [ { content: prompt, role: "user" } ],
|
messages: [ { content: prompt, role: "user" } ],
|
||||||
model: "claude-3-5-sonnet-latest",
|
model: "claude-sonnet-4-20250514",
|
||||||
system: `${personality} 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.`,
|
system: `${personality} 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.`,
|
||||||
temperature: 1,
|
temperature: 1,
|
||||||
});
|
});
|
||||||
@ -45,4 +48,10 @@ export const query = async(
|
|||||||
|
|
||||||
const { usage } = messages;
|
const { usage } = messages;
|
||||||
await calculateCost(usage, interaction.user.username, "query");
|
await calculateCost(usage, interaction.user.username, "query");
|
||||||
|
} catch (error) {
|
||||||
|
await replyToError(interaction);
|
||||||
|
if (error instanceof Error) {
|
||||||
|
await logger.error("query command", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
@ -8,6 +8,8 @@ import { personality } from "../config/personality.js";
|
|||||||
import { ai } from "../utils/ai.js";
|
import { ai } from "../utils/ai.js";
|
||||||
import { calculateCost } from "../utils/calculateCost.js";
|
import { calculateCost } from "../utils/calculateCost.js";
|
||||||
import { isSubscribed } from "../utils/isSubscribed.js";
|
import { isSubscribed } from "../utils/isSubscribed.js";
|
||||||
|
import { logger } from "../utils/logger.js";
|
||||||
|
import { replyToError } from "../utils/replyToError.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Accepts a text snippet from the user. Submits it to Anthropic
|
* Accepts a text snippet from the user. Submits it to Anthropic
|
||||||
@ -17,6 +19,7 @@ import { isSubscribed } from "../utils/isSubscribed.js";
|
|||||||
export const summarise = async(
|
export const summarise = async(
|
||||||
interaction: ChatInputCommandInteraction,
|
interaction: ChatInputCommandInteraction,
|
||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
|
try {
|
||||||
await interaction.deferReply({ flags: [ MessageFlags.Ephemeral ] });
|
await interaction.deferReply({ flags: [ MessageFlags.Ephemeral ] });
|
||||||
const sub = await isSubscribed(interaction);
|
const sub = await isSubscribed(interaction);
|
||||||
if (!sub) {
|
if (!sub) {
|
||||||
@ -29,7 +32,7 @@ export const summarise = async(
|
|||||||
// eslint-disable-next-line @typescript-eslint/naming-convention -- Required key format for SDK.
|
// eslint-disable-next-line @typescript-eslint/naming-convention -- Required key format for SDK.
|
||||||
max_tokens: 2000,
|
max_tokens: 2000,
|
||||||
messages: [ { content: prompt, role: "user" } ],
|
messages: [ { content: prompt, role: "user" } ],
|
||||||
model: "claude-3-5-sonnet-latest",
|
model: "claude-sonnet-4-20250514",
|
||||||
system: `${personality} Your role in this conversation is to summarise the text the user has provided. Your goal is to reach 250 words or less. Wrap ONLY THE SUMMARY in multi-line code block so it is easy to copy.`,
|
system: `${personality} Your role in this conversation is to summarise the text the user has provided. Your goal is to reach 250 words or less. Wrap ONLY THE SUMMARY in multi-line code block so it is easy to copy.`,
|
||||||
temperature: 1,
|
temperature: 1,
|
||||||
});
|
});
|
||||||
@ -45,4 +48,10 @@ export const summarise = async(
|
|||||||
|
|
||||||
const { usage } = messages;
|
const { usage } = messages;
|
||||||
await calculateCost(usage, interaction.user.username, "summarise");
|
await calculateCost(usage, interaction.user.username, "summarise");
|
||||||
|
} catch (error) {
|
||||||
|
await replyToError(interaction);
|
||||||
|
if (error instanceof Error) {
|
||||||
|
await logger.error("summarise command", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
@ -19,6 +19,7 @@ const html = `<!DOCTYPE html>
|
|||||||
<body>
|
<body>
|
||||||
<main>
|
<main>
|
||||||
<h1>Cordelia Taryne</h1>
|
<h1>Cordelia Taryne</h1>
|
||||||
|
<img src="https://cdn.nhcarrigan.com/new-avatars/cordelia-full.png" width="250" alt="Cordelia" />
|
||||||
<section>
|
<section>
|
||||||
<p>AI-powered multi-purpose assistant for Discord!</p>
|
<p>AI-powered multi-purpose assistant for Discord!</p>
|
||||||
</section>
|
</section>
|
||||||
|
@ -26,7 +26,7 @@ export const isSubscribed = async(
|
|||||||
if (!isEntitled && interaction.user.id !== "465650873650118659") {
|
if (!isEntitled && interaction.user.id !== "465650873650118659") {
|
||||||
const subscribeButton = new ButtonBuilder().
|
const subscribeButton = new ButtonBuilder().
|
||||||
setStyle(ButtonStyle.Premium).
|
setStyle(ButtonStyle.Premium).
|
||||||
setSKUId("1338596712121499669");
|
setSKUId("1338672773261951026");
|
||||||
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(
|
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(
|
||||||
subscribeButton,
|
subscribeButton,
|
||||||
);
|
);
|
||||||
|
38
src/utils/replyToError.ts
Normal file
38
src/utils/replyToError.ts
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/**
|
||||||
|
* @copyright nhcarrigan
|
||||||
|
* @license Naomi's Public License
|
||||||
|
* @author Naomi Carrigan
|
||||||
|
*/
|
||||||
|
import {
|
||||||
|
ActionRowBuilder,
|
||||||
|
ButtonBuilder,
|
||||||
|
ButtonStyle,
|
||||||
|
type ChatInputCommandInteraction,
|
||||||
|
type MessageContextMenuCommandInteraction,
|
||||||
|
} from "discord.js";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Responds to an interaction with a generic error message.
|
||||||
|
* @param interaction -- The interaction payload from Discord.
|
||||||
|
*/
|
||||||
|
export const replyToError = async(
|
||||||
|
interaction:
|
||||||
|
| ChatInputCommandInteraction
|
||||||
|
| MessageContextMenuCommandInteraction,
|
||||||
|
): Promise<void> => {
|
||||||
|
const button = new ButtonBuilder().setLabel("Need help?").
|
||||||
|
setStyle(ButtonStyle.Link).
|
||||||
|
setURL("https://chat.nhcarrigan.com");
|
||||||
|
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(button);
|
||||||
|
if (interaction.deferred || interaction.replied) {
|
||||||
|
await interaction.editReply({
|
||||||
|
components: [ row ],
|
||||||
|
content: "An error occurred while running this command.",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await interaction.reply({
|
||||||
|
components: [ row ],
|
||||||
|
content: "An error occurred while running this command.",
|
||||||
|
});
|
||||||
|
};
|
Reference in New Issue
Block a user