generated from nhcarrigan/template
This commit is contained in:
@@ -1,34 +0,0 @@
|
||||
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=becca-lyria
|
||||
|
||||
- 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"
|
||||
+2
-1
@@ -24,7 +24,8 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@anthropic-ai/sdk": "0.52.0",
|
||||
"@nhcarrigan/logger": "1.0.0",
|
||||
"@nhcarrigan/discord-analytics": "0.0.6",
|
||||
"@nhcarrigan/logger": "1.1.1",
|
||||
"discord.js": "14.19.3",
|
||||
"fastify": "5.3.3"
|
||||
}
|
||||
|
||||
Generated
+54
-5
@@ -11,9 +11,12 @@ importers:
|
||||
'@anthropic-ai/sdk':
|
||||
specifier: 0.52.0
|
||||
version: 0.52.0
|
||||
'@nhcarrigan/discord-analytics':
|
||||
specifier: 0.0.6
|
||||
version: 0.0.6(@nhcarrigan/logger@1.1.1)(discord.js@14.19.3)
|
||||
'@nhcarrigan/logger':
|
||||
specifier: 1.0.0
|
||||
version: 1.0.0
|
||||
specifier: 1.1.1
|
||||
version: 1.1.1
|
||||
discord.js:
|
||||
specifier: 14.19.3
|
||||
version: 14.19.3
|
||||
@@ -423,6 +426,12 @@ packages:
|
||||
'@jridgewell/trace-mapping@0.3.25':
|
||||
resolution: {integrity: sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==}
|
||||
|
||||
'@nhcarrigan/discord-analytics@0.0.6':
|
||||
resolution: {integrity: sha512-Mci/zSY2nE24BM2cZx5EiYqwpRTTCBznFfs2BphejzDAaWPt1P12V5ln7OSUbFLGhvTD/Qwi0za3yPv6shQLoA==}
|
||||
peerDependencies:
|
||||
'@nhcarrigan/logger': '>=1.1.0-hotfix'
|
||||
discord.js: ^14.0.0
|
||||
|
||||
'@nhcarrigan/eslint-config@5.2.0':
|
||||
resolution: {integrity: sha512-YpTTqhviKMlRwKF+RC/GYiA5i2jTCmg8uftuiufldneNV5HMbGpTfBbV7tpa8++5mpYJc4+eZaf40QbDiz84dQ==}
|
||||
engines: {node: '>=22', pnpm: '>=9'}
|
||||
@@ -433,8 +442,8 @@ packages:
|
||||
typescript: '>=5'
|
||||
vitest: '>=2'
|
||||
|
||||
'@nhcarrigan/logger@1.0.0':
|
||||
resolution: {integrity: sha512-2e19Bie+ZKb6yKPKjhawqsENkhHatYkvBAmFZx9eToOXdOca+CYi51tldRMtejg6e0+4hOOf2bo5zdBQKmH0dw==}
|
||||
'@nhcarrigan/logger@1.1.1':
|
||||
resolution: {integrity: sha512-P6OEQFHDtf6psybYGljuCxkSW6DLQCsx1aZZ3w4YKBXHBFjDbhuvpM9K1kPhVN48hakitx2WPLEoIFr6YZELYw==}
|
||||
|
||||
'@nhcarrigan/typescript-config@4.0.0':
|
||||
resolution: {integrity: sha512-969HVha7A/Sg77fuMwOm6p14a+7C5iE6g55OD71srqwKIgksQl+Ex/hAI/pyzTQFDQ/FBJbpnHlR4Ov25QV/rw==}
|
||||
@@ -948,6 +957,10 @@ packages:
|
||||
core-js-compat@3.40.0:
|
||||
resolution: {integrity: sha512-0XEDpr5y5mijvw8Lbc6E5AkjrHfp7eEoPlu36SWeAbcL8fn1G1ANe8DBlo2XoNN89oVpxWwOjYIPVzR4ZvsKCQ==}
|
||||
|
||||
cron-parser@4.9.0:
|
||||
resolution: {integrity: sha512-p0SaNjrHOnQeR8/VnfGbmg9te2kfyYSQ7Sc/j/6DtPL3JQvKxmjO9TSjNFpujqV3vEYYBvNNvXSxzyksBWAx1Q==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
|
||||
cross-spawn@7.0.6:
|
||||
resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==}
|
||||
engines: {node: '>= 8'}
|
||||
@@ -1648,6 +1661,9 @@ packages:
|
||||
lodash@4.17.21:
|
||||
resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==}
|
||||
|
||||
long-timeout@0.1.1:
|
||||
resolution: {integrity: sha512-BFRuQUqc7x2NWxfJBCyUrN8iYUYznzL9JROmRz1gZ6KlOIgmoD+njPVbb+VNn2nGMKggMsK79iUNErillsrx7w==}
|
||||
|
||||
loose-envify@1.4.0:
|
||||
resolution: {integrity: sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==}
|
||||
hasBin: true
|
||||
@@ -1661,6 +1677,10 @@ packages:
|
||||
lru-cache@5.1.1:
|
||||
resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==}
|
||||
|
||||
luxon@3.7.2:
|
||||
resolution: {integrity: sha512-vtEhXh/gNjI9Yg1u4jX/0YVPMvxzHuGgCm6tC5kZyb08yjGWGnqAjGJvcXbqQR2P3MyMEFnRbpcdFS6PBcLqew==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
magic-bytes.js@1.10.0:
|
||||
resolution: {integrity: sha512-/k20Lg2q8LE5xiaaSkMXk4sfvI+9EGEykFS4b0CHHGWqDYU0bGUFSwchNOMA56D7TCs9GwVTkqe9als1/ns8UQ==}
|
||||
|
||||
@@ -1718,6 +1738,10 @@ packages:
|
||||
node-releases@2.0.19:
|
||||
resolution: {integrity: sha512-xxOWJsBKtzAq7DY0J+DTzuz58K8e7sJbdgwkbMWQe8UYB6ekmsQ45q0M/tJDsGaZmbC+l7n57UV8Hl5tHxO9uw==}
|
||||
|
||||
node-schedule@2.1.1:
|
||||
resolution: {integrity: sha512-OXdegQq03OmXEjt2hZP33W2YPs/E5BcFQks46+G2gAxs4gHOIVD1u7EqlYLYSKsaIpyKCK9Gbk0ta1/gjRSMRQ==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
normalize-package-data@2.5.0:
|
||||
resolution: {integrity: sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==}
|
||||
|
||||
@@ -2058,6 +2082,9 @@ packages:
|
||||
sonic-boom@4.2.0:
|
||||
resolution: {integrity: sha512-INb7TM37/mAcsGmc9hyyI6+QR3rR1zVRu36B0NeGXKnOOLiZOfER5SA+N7X7k3yUYRzLWafduTDvJAfDswwEww==}
|
||||
|
||||
sorted-array-functions@1.3.0:
|
||||
resolution: {integrity: sha512-2sqgzeFlid6N4Z2fUQ1cvFmTOLRi/sEDzSQ0OKYchqgoPmQBVyM3959qYx3fpS6Esef80KjmpgPeEr028dP3OA==}
|
||||
|
||||
source-map-js@1.2.1:
|
||||
resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
@@ -2764,6 +2791,12 @@ snapshots:
|
||||
'@jridgewell/resolve-uri': 3.1.2
|
||||
'@jridgewell/sourcemap-codec': 1.5.0
|
||||
|
||||
'@nhcarrigan/discord-analytics@0.0.6(@nhcarrigan/logger@1.1.1)(discord.js@14.19.3)':
|
||||
dependencies:
|
||||
'@nhcarrigan/logger': 1.1.1
|
||||
discord.js: 14.19.3
|
||||
node-schedule: 2.1.1
|
||||
|
||||
'@nhcarrigan/eslint-config@5.2.0(@typescript-eslint/utils@8.24.0(eslint@9.27.0)(typescript@5.8.3))(eslint@9.27.0)(playwright@1.50.1)(react@19.0.0)(typescript@5.8.3)(vitest@3.1.4(@types/node@22.15.21))':
|
||||
dependencies:
|
||||
'@eslint-community/eslint-plugin-eslint-comments': 4.4.1(eslint@9.27.0)
|
||||
@@ -2793,7 +2826,7 @@ snapshots:
|
||||
- eslint-import-resolver-webpack
|
||||
- supports-color
|
||||
|
||||
'@nhcarrigan/logger@1.0.0': {}
|
||||
'@nhcarrigan/logger@1.1.1': {}
|
||||
|
||||
'@nhcarrigan/typescript-config@4.0.0(typescript@5.8.3)':
|
||||
dependencies:
|
||||
@@ -3345,6 +3378,10 @@ snapshots:
|
||||
dependencies:
|
||||
browserslist: 4.24.4
|
||||
|
||||
cron-parser@4.9.0:
|
||||
dependencies:
|
||||
luxon: 3.7.2
|
||||
|
||||
cross-spawn@7.0.6:
|
||||
dependencies:
|
||||
path-key: 3.1.1
|
||||
@@ -4254,6 +4291,8 @@ snapshots:
|
||||
|
||||
lodash@4.17.21: {}
|
||||
|
||||
long-timeout@0.1.1: {}
|
||||
|
||||
loose-envify@1.4.0:
|
||||
dependencies:
|
||||
js-tokens: 4.0.0
|
||||
@@ -4266,6 +4305,8 @@ snapshots:
|
||||
dependencies:
|
||||
yallist: 3.1.1
|
||||
|
||||
luxon@3.7.2: {}
|
||||
|
||||
magic-bytes.js@1.10.0: {}
|
||||
|
||||
magic-string@0.30.17:
|
||||
@@ -4313,6 +4354,12 @@ snapshots:
|
||||
|
||||
node-releases@2.0.19: {}
|
||||
|
||||
node-schedule@2.1.1:
|
||||
dependencies:
|
||||
cron-parser: 4.9.0
|
||||
long-timeout: 0.1.1
|
||||
sorted-array-functions: 1.3.0
|
||||
|
||||
normalize-package-data@2.5.0:
|
||||
dependencies:
|
||||
hosted-git-info: 2.8.9
|
||||
@@ -4694,6 +4741,8 @@ snapshots:
|
||||
dependencies:
|
||||
atomic-sleep: 1.0.0
|
||||
|
||||
sorted-array-functions@1.3.0: {}
|
||||
|
||||
source-map-js@1.2.1: {}
|
||||
|
||||
spdx-correct@3.2.0:
|
||||
|
||||
@@ -21,7 +21,7 @@ import type { MessageParam } from "@anthropic-ai/sdk/resources/index.js";
|
||||
* Handles the Discord message event.
|
||||
* @param message - The message payload from Discord.
|
||||
*/
|
||||
// eslint-disable-next-line max-lines-per-function, max-statements -- We're off by one bloody line.
|
||||
// eslint-disable-next-line max-lines-per-function, max-statements, complexity -- We're off by one bloody line.
|
||||
export const onMessage = async(message: Message): Promise<void> => {
|
||||
try {
|
||||
if (message.channel.type !== ChannelType.DM) {
|
||||
@@ -79,8 +79,11 @@ export const onMessage = async(message: Message): Promise<void> => {
|
||||
}
|
||||
|
||||
await calculateCost(messages.usage, message.author.username);
|
||||
await logger.metric("messages_processed", 1, { user: message.author.id });
|
||||
} catch (error) {
|
||||
await logger.error("message event", error as Error);
|
||||
await logger.error("message event", error instanceof Error
|
||||
? error
|
||||
: new Error(String(error)));
|
||||
const button = new ButtonBuilder().
|
||||
setLabel("Need help?").
|
||||
setStyle(ButtonStyle.Link).
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* @license Naomi's Public License
|
||||
* @author Naomi Carrigan
|
||||
*/
|
||||
import { DiscordAnalytics } from "@nhcarrigan/discord-analytics";
|
||||
import { Client, Events, GatewayIntentBits, Partials } from "discord.js";
|
||||
import { onMessage } from "./events/message.js";
|
||||
import { about } from "./modules/about.js";
|
||||
@@ -33,7 +34,10 @@ const client = new Client({
|
||||
partials: [ Partials.Channel ],
|
||||
});
|
||||
|
||||
const analytics = new DiscordAnalytics(client, logger);
|
||||
|
||||
client.on(Events.InteractionCreate, (interaction) => {
|
||||
void analytics.logGatewayEvent(Events.InteractionCreate, { ...interaction });
|
||||
if (interaction.isChatInputCommand()) {
|
||||
switch (interaction.commandName) {
|
||||
case "about":
|
||||
@@ -69,6 +73,7 @@ client.on(Events.EntitlementDelete, (entitlement) => {
|
||||
|
||||
client.on(Events.ClientReady, () => {
|
||||
void logger.log("debug", "Bot is ready.");
|
||||
analytics.startCron();
|
||||
});
|
||||
|
||||
instantiateServer();
|
||||
|
||||
Reference in New Issue
Block a user