feat: initial prototype
Node.js CI / Lint and Test (push) Failing after 36s

This commit is contained in:
2025-07-30 13:50:50 -07:00
parent 9cf5daddc5
commit f5dd45a4c4
12 changed files with 4898 additions and 0 deletions
+38
View File
@@ -0,0 +1,38 @@
name: Node.js CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
lint:
name: Lint and Test
steps:
- name: Checkout Source Files
uses: actions/checkout@v4
- name: Use Node.js v22
uses: actions/setup-node@v4
with:
node-version: 22
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 9
- name: Install Dependencies
run: pnpm install
- name: Lint Source Files
run: pnpm run lint
- name: Verify Build
run: pnpm run build
- name: Run Tests
run: pnpm run test
+2
View File
@@ -0,0 +1,2 @@
node_modules
prod
+6
View File
@@ -0,0 +1,6 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
},
"eslint.validate": ["typescript"],
}
+5
View File
@@ -0,0 +1,5 @@
import NaomisConfig from '@nhcarrigan/eslint-config';
export default [
...NaomisConfig,
];
+31
View File
@@ -0,0 +1,31 @@
{
"name": "womp-womp",
"version": "0.0.0",
"description": "WOMP WOMP",
"type": "module",
"main": "index.js",
"scripts": {
"build": "tsc",
"start": "op run --env-file=prod.env -- node prod/index.js",
"dev": "tsx src/index.ts",
"lint": "eslint src --max-warnings=0",
"test": "echo \"Error: no test specified\" && exit 0"
},
"keywords": [],
"author": "",
"license": "ISC",
"packageManager": "pnpm@10.13.1",
"devDependencies": {
"@nhcarrigan/eslint-config": "5.2.0",
"@nhcarrigan/typescript-config": "4.0.0",
"eslint": "9.32.0",
"tsx": "4.20.3",
"typescript": "5.8.3"
},
"dependencies": {
"@nhcarrigan/logger": "1.0.0",
"discord.js": "14.21.0",
"fastify": "5.4.0",
"remove-markdown": "0.6.2"
}
}
+4665
View File
File diff suppressed because it is too large Load Diff
+2
View File
@@ -0,0 +1,2 @@
BOT_TOKEN="op://Environment Variables - Naomi/WOMP WOMP/discord token"
LOG_TOKEN="op://Environment Variables - Naomi/Alert Server/api_auth"
+56
View File
@@ -0,0 +1,56 @@
/**
* @copyright nhcarrigan
* @license Naomi's Public License
* @author Naomi Carrigan
*/
import {
Client,
Events,
GatewayIntentBits,
} from "discord.js";
import removeMd from "remove-markdown";
import { instantiateServer } from "./server/serve.js";
import { logger } from "./utils/logger.js";
const womp = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],
});
womp.once(Events.ClientReady, () => {
void logger.log(
"debug",
`Logged in as ${womp.user?.username ?? "unknown"}`,
);
});
womp.on(Events.MessageCreate, (message) => {
if (!message.inGuild()) {
return;
}
if (message.author.bot) {
return;
}
if (message.channel.id !== "1400215966918512750") {
return;
}
const cleaned = removeMd(message.content);
const wompRegex = /^(?:\s*womp\s*)+$/i;
if (wompRegex.test(cleaned)) {
return;
}
void message.delete().catch((error: unknown) => {
if (error instanceof Error) {
void logger.error("message delete", error);
return;
}
void logger.error("message delete", new Error(String(error)));
});
});
await womp.login(process.env.DISCORD_TOKEN);
instantiateServer();
+60
View File
@@ -0,0 +1,60 @@
/**
* @copyright nhcarrigan
* @license Naomi's Public License
* @author Naomi Carrigan
*/
import fastify from "fastify";
import { logger } from "../utils/logger.js";
const html = `<!DOCTYPE html>
<html>
<head>
<title>WOMP WOMP</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="WOMP WOMP" />
<script src="https://cdn.nhcarrigan.com/headers/index.js" async defer></script>
</head>
<body>
<main>
<h1>WOMP WOMP</h1>
<img src="https://c.tenor.com/vB3nSgDEV98AAAAd/tenor.gif" width="250" alt="WOMP WOMP" />
<section>
<a href="https://discord.gg/KKe7BaEnQB" class="social-button discord-button" style="display: inline-block; background-color: #5865F2; color: white; padding: 10px 20px; text-decoration: none; border-radius: 4px; margin: 5px;">
<i class="fab fa-discord"></i> Join the Womp Womp Club
</a>
</section>
</main>
</body>
</html>`;
/**
* Starts up a web server for health monitoring.
*/
export const instantiateServer = (): void => {
try {
const server = fastify({
logger: false,
});
server.get("/", (_request, response) => {
response.header("Content-Type", "text/html");
response.send(html);
});
server.listen({ port: 5033 }, (error) => {
if (error) {
void logger.error("instantiate server", error);
return;
}
void logger.log("debug", "Server listening on port 5033.");
});
} catch (error) {
if (error instanceof Error) {
void logger.error("instantiate server", error);
return;
}
void logger.error("instantiate server", new Error(String(error)));
}
};
+12
View File
@@ -0,0 +1,12 @@
/**
* @copyright nhcarrigan
* @license Naomi's Public License
* @author Naomi Carrigan
*/
import { Logger } from "@nhcarrigan/logger";
export const logger = new Logger(
"WOMP WOMP",
process.env.LOG_TOKEN ?? "",
);
+14
View File
@@ -0,0 +1,14 @@
import removeMarkdown from "remove-markdown";
const invalid = "# WOMP WOMP\nThis is bold and italic text.";
const valid = "# WOMP WOMP\nwomp womp\n\nWOMP";
const valid2 = "**womp womp**\n\n*WOMP WOMP*\n__womp womp__";
const invalid2 = "**womp womp**.";
const wompRegex = /^(?:\s*womp\s*)+$/i;
console.log(wompRegex.test(removeMarkdown(invalid)))
console.log(wompRegex.test(removeMarkdown(valid)))
console.log(wompRegex.test(removeMarkdown(valid2)))
console.log(wompRegex.test(removeMarkdown(invalid2)))
+7
View File
@@ -0,0 +1,7 @@
{
"extends": "@nhcarrigan/typescript-config",
"compilerOptions": {
"outDir": "./prod",
"rootDir": "./src",
}
}