generated from nhcarrigan/template
WIP: Initial bot prototype #7
@@ -0,0 +1,40 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ci:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Check dependency pinning
|
||||||
|
uses: naomi-lgbt/dependency-pin-check@main
|
||||||
|
|
||||||
|
- uses: pnpm/action-setup@v4
|
||||||
|
with:
|
||||||
|
version: 9
|
||||||
|
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "20"
|
||||||
|
cache: "pnpm"
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: pnpm install
|
||||||
|
|
||||||
|
- name: Run linter
|
||||||
|
run: pnpm lint
|
||||||
|
|
||||||
|
- name: Build project
|
||||||
|
run: pnpm build
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: pnpm test
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
node_modules
|
||||||
|
prod
|
||||||
@@ -1,16 +1,6 @@
|
|||||||
# New Repository Template
|
# Rondelle
|
||||||
|
|
||||||
This template contains all of our basic files for a new GitHub repository. There is also a handy workflow that will create an issue on a new repository made from this template, with a checklist for the steps we usually take in setting up a new repository.
|
A Discord bot to facilitate coffee chats or breakouts.
|
||||||
|
|
||||||
If you're starting a Node.JS project with TypeScript, we have a [specific template](https://github.com/naomi-lgbt/nodejs-typescript-template) for that purpose.
|
|
||||||
|
|
||||||
## Readme
|
|
||||||
|
|
||||||
Delete all of the above text (including this line), and uncomment the below text to use our standard readme template.
|
|
||||||
|
|
||||||
<!-- # Project Name
|
|
||||||
|
|
||||||
Project Description
|
|
||||||
|
|
||||||
## Live Version
|
## Live Version
|
||||||
|
|
||||||
@@ -36,4 +26,4 @@ Copyright held by Naomi Carrigan.
|
|||||||
|
|
||||||
## Contact
|
## Contact
|
||||||
|
|
||||||
We may be contacted through our [Chat Server](http://chat.nhcarrigan.com) or via email at `contact@nhcarrigan.com`. -->
|
We may be contacted through our [Chat Server](http://chat.nhcarrigan.com) or via email at `contact@nhcarrigan.com`.
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
import NaomisConfig from "@nhcarrigan/eslint-config";
|
||||||
|
|
||||||
|
export default [
|
||||||
|
...NaomisConfig,
|
||||||
|
];
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
{
|
||||||
|
"name": "rondelle",
|
||||||
|
"pnpm": {
|
||||||
|
"onlyBuiltDependencies": [
|
||||||
|
"@prisma/engines",
|
||||||
|
"esbuild",
|
||||||
|
"prisma"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"version": "0.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "./prod/index.js",
|
||||||
|
"scripts": {
|
||||||
|
"build": "tsc",
|
||||||
|
"start": "op run --env-file=prod.env -- node prod/index.js",
|
||||||
|
"lint": "eslint src --max-warnings 0",
|
||||||
|
"test": "echo \"No tests yet\" && exit 0"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "Naomi Carrigan <contact@nhcarrigan.com>",
|
||||||
|
"license": "See LICENSE.md",
|
||||||
|
"type": "module",
|
||||||
|
"devDependencies": {
|
||||||
|
"@nhcarrigan/eslint-config": "5.2.0",
|
||||||
|
"@nhcarrigan/typescript-config": "4.0.0",
|
||||||
|
"@types/node": "22.10.6",
|
||||||
|
"prisma": "6.8.2",
|
||||||
|
"typescript": "5.7.3"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@nhcarrigan/logger": "1.1.1",
|
||||||
|
"@prisma/client": "6.8.2",
|
||||||
|
"discord.js": "14.25.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
Generated
+4397
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,35 @@
|
|||||||
|
generator client {
|
||||||
|
provider = "prisma-client-js"
|
||||||
|
}
|
||||||
|
|
||||||
|
datasource db {
|
||||||
|
provider = "mongodb"
|
||||||
|
url = env("MONGO_URI")
|
||||||
|
}
|
||||||
|
|
||||||
|
model ServerEvent {
|
||||||
|
id String @id @default(auto()) @map("_id") @db.ObjectId
|
||||||
|
serverId String
|
||||||
|
eventId String
|
||||||
|
eventName String
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
createdBy String
|
||||||
|
|
||||||
|
@@unique([serverId, eventId])
|
||||||
|
@@index([serverId])
|
||||||
|
}
|
||||||
|
|
||||||
|
model UserPairingHistory {
|
||||||
|
id String @id @default(auto()) @map("_id") @db.ObjectId
|
||||||
|
userId String
|
||||||
|
serverId String
|
||||||
|
pairings PairingRecord[]
|
||||||
|
|
||||||
|
@@unique([userId, serverId])
|
||||||
|
}
|
||||||
|
|
||||||
|
type PairingRecord {
|
||||||
|
recipientId String
|
||||||
|
eventId String
|
||||||
|
sessionDate DateTime
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# 1Password vault references - safe to commit
|
||||||
|
# Run with: op run --env-file=prod.env -- <command>
|
||||||
|
|
||||||
|
# Example environment variables
|
||||||
|
DATABASE_URL=op://Development/rondelle-database/connection-string
|
||||||
|
API_KEY=op://Development/rondelle-api/api-key
|
||||||
|
SECRET_TOKEN=op://Development/rondelle-secrets/token
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
/**
|
||||||
|
* @copyright 2026
|
||||||
|
* @license Naomi's Public License
|
||||||
|
* @author Naomi Carrigan
|
||||||
|
*/
|
||||||
|
import { Client, GatewayIntentBits } from "discord.js";
|
||||||
|
import { instantiatePrisma } from "./utils/database.js";
|
||||||
|
import { logger } from "./utils/logger.js";
|
||||||
|
import type { Rondelle } from "./interfaces/rondelle.js";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts the Discord bot and connects to the database.
|
||||||
|
*/
|
||||||
|
const startBot = async(): Promise<void> => {
|
||||||
|
const rondelle: Rondelle = {
|
||||||
|
database: await instantiatePrisma(),
|
||||||
|
discord: new Client({
|
||||||
|
intents: [ GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates ],
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
rondelle.discord.once("ready", () => {
|
||||||
|
void logger.log("info", `Logged in as ${rondelle.discord.user?.tag ?? "unknown"}`);
|
||||||
|
});
|
||||||
|
|
||||||
|
await rondelle.discord.login(process.env.DISCORD_TOKEN);
|
||||||
|
};
|
||||||
|
|
||||||
|
await startBot().catch(async(error: unknown) => {
|
||||||
|
const actualError = error instanceof Error
|
||||||
|
? error
|
||||||
|
: new Error(String(error));
|
||||||
|
await logger.error("startBot", actualError);
|
||||||
|
});
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
/**
|
||||||
|
* @copyright 2026
|
||||||
|
* @license Naomi's Public License
|
||||||
|
* @author Naomi Carrigan
|
||||||
|
*/
|
||||||
|
import type { PrismaClient } from "@prisma/client";
|
||||||
|
import type { Client } from "discord.js";
|
||||||
|
|
||||||
|
interface Rondelle {
|
||||||
|
database: PrismaClient;
|
||||||
|
discord: Client;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type { Rondelle };
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
/**
|
||||||
|
* @copyright 2026
|
||||||
|
* @license Naomi's Public License
|
||||||
|
* @author Naomi Carrigan
|
||||||
|
*/
|
||||||
|
import { PrismaClient } from "@prisma/client";
|
||||||
|
import { logger } from "./logger.js";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates and connects a Prisma client instance.
|
||||||
|
* @returns The connected Prisma client.
|
||||||
|
*/
|
||||||
|
const instantiatePrisma = async(): Promise<PrismaClient> => {
|
||||||
|
const client = new PrismaClient();
|
||||||
|
await client.$connect();
|
||||||
|
await logger.log("info", "Connected to database.");
|
||||||
|
return client;
|
||||||
|
};
|
||||||
|
|
||||||
|
export { instantiatePrisma };
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
/**
|
||||||
|
* @copyright 2026
|
||||||
|
* @license Naomi's Public License
|
||||||
|
* @author Naomi Carrigan
|
||||||
|
*/
|
||||||
|
import { Logger } from "@nhcarrigan/logger";
|
||||||
|
|
||||||
|
const logger = new Logger(
|
||||||
|
"rondelle",
|
||||||
|
process.env.LOG_TOKEN ?? "",
|
||||||
|
);
|
||||||
|
|
||||||
|
export { logger };
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"extends": "@nhcarrigan/typescript-config",
|
||||||
|
"compilerOptions": {
|
||||||
|
"rootDir": "./src",
|
||||||
|
"outDir": "./prod",
|
||||||
|
},
|
||||||
|
"include": ["src/**/*"]
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user