Skip to content

Commit

Permalink
feat: initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisakura committed Jun 2, 2024
0 parents commit 9cdc3d4
Show file tree
Hide file tree
Showing 29 changed files with 3,708 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# top-most EditorConfig file
root = true

[*]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DISCORD_TOKEN=
61 changes: 61 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"ignorePatterns": ["dist"],
"plugins": ["simple-import-sort", "unused-imports"],
"rules": {
"quotes": ["error", "double", { "avoidEscape": true }],
"jsx-quotes": ["error", "prefer-double"],
"no-mixed-spaces-and-tabs": "error",
"arrow-parens": ["error", "as-needed"],
"eol-last": ["error", "always"],
"func-call-spacing": ["error", "never"],
"no-multi-spaces": "error",
"no-trailing-spaces": "error",
"no-whitespace-before-property": "error",
"semi": ["error", "always"],
"semi-style": ["error", "last"],
"space-in-parens": ["error", "never"],
"block-spacing": ["error", "always"],
"object-curly-spacing": ["error", "always"],
"eqeqeq": ["error", "always", { "null": "ignore" }],
"spaced-comment": ["error", "always", { "markers": ["!"] }],
"yoda": "error",
"prefer-destructuring": ["error", {
"VariableDeclarator": { "array": false, "object": true },
"AssignmentExpression": { "array": false, "object": false }
}],
"operator-assignment": ["error", "always"],
"no-useless-computed-key": "error",
"no-unneeded-ternary": ["error", { "defaultAssignment": false }],
"no-invalid-regexp": "error",
"no-constant-condition": ["error", { "checkLoops": false }],
"no-duplicate-imports": "error",
"no-extra-semi": "error",
"dot-notation": "error",
"no-useless-escape": "error",
"no-fallthrough": "error",
"for-direction": "error",
"no-async-promise-executor": "error",
"no-cond-assign": "error",
"no-dupe-else-if": "error",
"no-duplicate-case": "error",
"no-irregular-whitespace": "error",
"no-loss-of-precision": "error",
"no-misleading-character-class": "error",
"no-prototype-builtins": "error",
"no-regex-spaces": "error",
"no-shadow-restricted-names": "error",
"no-unexpected-multiline": "error",
"no-unsafe-optional-chaining": "error",
"no-useless-backreference": "error",
"use-isnan": "error",
"prefer-const": "error",
"prefer-spread": "error",

"simple-import-sort/imports": "error",
"simple-import-sort/exports": "error",

"unused-imports/no-unused-imports": "error"
}
}
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
dist
node_modules
.env

sqlite.db
661 changes: 661 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Venniepoints

Venniepoints is a Discord bot used on the [Vencord](https://vencord.dev) Discord server for experience points!

This bot is extremely specific and not configurable so there is really no reason for you to want to self host it

Nevertheless it is still available under a free software license so you can easily audit and modify it!
50 changes: 50 additions & 0 deletions build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import esbuild from "esbuild";
import { readdir } from "fs/promises";

/**
* @type {esbuild.Plugin}
*/
const makeAllPackagesExternalPlugin = {
name: "make-all-packages-external",
setup(build) {
const filter = /^[^./]|^\.[^./]|^\.\.[^/]/; // Must not start with "/" or "./" or "../"
build.onResolve({ filter }, args => ({ path: args.path, external: true }));
},
};

/**
* @type {(namespace: string) => esbuild.Plugin}
*/
const includeDirPlugin = namespace => ({
name: `include-dir-plugin:${namespace}`,
setup(build) {
const filter = new RegExp(`^~${namespace}$`);
const dir = `./src/${namespace}`;

build.onResolve(
{ filter },
args => ({ path: args.path, namespace })
);

build.onLoad({ filter, namespace }, async () => {
const files = await readdir(dir);
return {
contents: files.map(f => `import "./${f.replace(".ts", "")}"`).join("\n"),
resolveDir: dir
};
});
}
});

await esbuild.build({
entryPoints: ["src/index.ts"],
bundle: true,
plugins: [includeDirPlugin("commands"), includeDirPlugin("modules"), makeAllPackagesExternalPlugin],
outfile: "dist/index.js",
minify: false,
treeShaking: true,
target: "esnext",
platform: "node",
sourcemap: "linked",
logLevel: "info"
});
11 changes: 11 additions & 0 deletions drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineConfig } from "drizzle-kit";

export default defineConfig({
schema: "./src/schema.ts",
dialect: "sqlite",
dbCredentials: {
url: "./sqlite.db"
},
verbose: true,
strict: true
});
4 changes: 4 additions & 0 deletions drizzle/0000_sharp_vindicator.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CREATE TABLE `users` (
`id` text PRIMARY KEY NOT NULL,
`xp` integer NOT NULL
);
40 changes: 40 additions & 0 deletions drizzle/meta/0000_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"version": "6",
"dialect": "sqlite",
"id": "60b22056-c5e2-44b5-b23b-6c7f9daa0730",
"prevId": "00000000-0000-0000-0000-000000000000",
"tables": {
"users": {
"name": "users",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"xp": {
"name": "xp",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
}
},
"enums": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
},
"internal": {
"indexes": {}
}
}
13 changes: 13 additions & 0 deletions drizzle/meta/_journal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": "7",
"dialect": "sqlite",
"entries": [
{
"idx": 0,
"version": "6",
"when": 1717336720864,
"tag": "0000_sharp_vindicator",
"breakpoints": true
}
]
}
39 changes: 39 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "venniepoints",
"version": "1.0.0",
"description": "",
"main": "dist/index.js",
"scripts": {
"start": "pnpm build && node . VENNIE",
"build": "node build.mjs",
"test": "pnpm lint && pnpm testTypes",
"testTypes": "tsc --noEmit",
"lint": "eslint . --ext .js,.ts",
"lint:fix": "pnpm lint --fix",
"db:generate": "drizzle-kit generate",
"db:migrate": "tsx ./src/migrate.ts"
},
"keywords": [],
"author": "lewisakura <[email protected]>",
"dependencies": {
"better-sqlite3": "^11.0.0",
"dotenv": "^16.4.5",
"drizzle-orm": "^0.31.0",
"execa": "^8.0.1",
"oceanic.js": "1.10.4",
"pako": "^2.1.0"
},
"devDependencies": {
"@types/better-sqlite3": "^7.6.10",
"@types/node": "^20.12.7",
"@typescript-eslint/parser": "^7.7.0",
"drizzle-kit": "^0.22.1",
"esbuild": "^0.20.2",
"eslint": "^8.46.0",
"eslint-plugin-simple-import-sort": "^12.1.0",
"eslint-plugin-unused-imports": "^3.1.0",
"tslib": "^2.6.2",
"tsx": "^4.11.0",
"typescript": "^5.4.5"
}
}
Loading

0 comments on commit 9cdc3d4

Please sign in to comment.