more boilerplate and config stuff
parent
1fc06fe9cb
commit
086c8612c4
|
@ -0,0 +1,3 @@
|
|||
MONGODB_USERNAME=root
|
||||
MONGODB_PASSWORD=do_not_use_in_prod
|
||||
PREFIX=//
|
|
@ -0,0 +1,4 @@
|
|||
TOKEN=
|
||||
MONGODB_USERNAME=
|
||||
MONGODB_PASSWORD=
|
||||
PREFIX=
|
|
@ -1,3 +1,4 @@
|
|||
node_modules
|
||||
dist
|
||||
/.env
|
||||
/.private
|
||||
|
|
10
.prettierrc
10
.prettierrc
|
@ -1,5 +1,13 @@
|
|||
{
|
||||
"tabWidth": 4,
|
||||
"useTabs": false,
|
||||
"trailingComma": "all"
|
||||
"trailingComma": "all",
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["**/*.yml", "**/*.yaml"],
|
||||
"options": {
|
||||
"tabWidth": 2
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
env:
|
||||
browser: true
|
||||
es2021: true
|
||||
browser: true
|
||||
es2021: true
|
||||
extends:
|
||||
- eslint:recommended
|
||||
- plugin:@typescript-eslint/recommended
|
||||
- eslint:recommended
|
||||
- plugin:@typescript-eslint/recommended
|
||||
parser: "@typescript-eslint/parser"
|
||||
parserOptions:
|
||||
ecmaVersion: latest
|
||||
sourceType: module
|
||||
ecmaVersion: latest
|
||||
sourceType: module
|
||||
plugins:
|
||||
- "@typescript-eslint"
|
||||
- "@typescript-eslint"
|
||||
rules:
|
||||
semi: ["warn", "always"]
|
||||
quotes: ["warn", "double"]
|
||||
semi: ["warn", "always"]
|
||||
quotes: ["warn", "double"]
|
||||
|
|
|
@ -4,22 +4,30 @@ import { config } from "dotenv";
|
|||
|
||||
const ENV_VARS = ["TOKEN"] as const;
|
||||
|
||||
const logger = createLogger();
|
||||
|
||||
config();
|
||||
if (process.env.NODE_ENV != "production") {
|
||||
logger.info("$NODE_ENV is not set; Loading .env.dev");
|
||||
config({ path: "../.env.dev" });
|
||||
}
|
||||
|
||||
checkEnv(ENV_VARS);
|
||||
const environment: { [key in (typeof ENV_VARS)[number]]: string } =
|
||||
ENV_VARS.reduce(
|
||||
(prev, cur) => ({ ...prev, [cur]: process.env[cur] ?? "" }),
|
||||
{},
|
||||
) as never;
|
||||
|
||||
const logger = createLogger();
|
||||
const client = new Client({
|
||||
baseURL: "https://revolt.chat/api",
|
||||
autoReconnect: true,
|
||||
});
|
||||
|
||||
client.loginBot(environment.TOKEN);
|
||||
await client.loginBot(environment.TOKEN);
|
||||
|
||||
client.once("ready", () => {
|
||||
logger.done(`Ready: Logged in as @${client.user?.username}!`);
|
||||
});
|
||||
|
||||
export { client, logger, environment };
|
||||
Promise.all([import("./modules/commands.js")]);
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
// import { Command } from "lib";
|
||||
import { client } from "../index.js";
|
||||
|
||||
const DEFAULT_PREFIX = process.env.PREFIX || "/";
|
||||
|
||||
client.on("messageCreate", async (message) => {
|
||||
console.log("msg =>", message.content);
|
||||
});
|
|
@ -1,15 +1,15 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"rootDir": "./src",
|
||||
"outDir": "./dist",
|
||||
"strict": true,
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "node",
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"esModuleInterop": true,
|
||||
"isolatedModules": true,
|
||||
"resolveJsonModule": true,
|
||||
"skipLibCheck": true
|
||||
}
|
||||
}
|
||||
"compilerOptions": {
|
||||
"rootDir": "./src",
|
||||
"outDir": "./dist",
|
||||
"strict": true,
|
||||
"target": "ESNext",
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "node",
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"esModuleInterop": true,
|
||||
"isolatedModules": true,
|
||||
"resolveJsonModule": true,
|
||||
"skipLibCheck": true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
# MongoDB database and Redis server for development
|
||||
# Run `scripts/dev_db.sh` to get this up
|
||||
|
||||
version: "3.1"
|
||||
services:
|
||||
db:
|
||||
image: mongo
|
||||
restart: no
|
||||
environment:
|
||||
MONGO_INITDB_ROOT_USERNAME: root
|
||||
MONGO_INITDB_ROOT_PASSWORD: do_not_use_in_prod
|
||||
ports:
|
||||
- 127.0.0.1:27017:27017
|
||||
volumes:
|
||||
- ./.private/db:/data/db:rw
|
||||
|
||||
redis:
|
||||
image: eqalpha/keydb
|
||||
restart: no
|
|
@ -1,2 +1,4 @@
|
|||
export * from "./misc/environment.js";
|
||||
export * from "./misc/logger.js";
|
||||
|
||||
export * from "./types/Command.js";
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
import { Permission } from "revolt.js/lib/esm/permissions/definitions";
|
||||
|
||||
export type Command = {
|
||||
name: string; // Primary name of the command
|
||||
aliases?: string[]; // Optional alias names
|
||||
description: string; // Short description of what the command does
|
||||
permissions?: (keyof typeof Permission)[]; // Static permissions required to execute the command
|
||||
run: () => any | Promise<any>;
|
||||
};
|
|
@ -0,0 +1,25 @@
|
|||
if command -v getenforce &> /dev/null; then
|
||||
if [ "$(getenforce)" == "Enforcing" ]; then
|
||||
echo "SELinux is currently set to enforce security policies, which will most likely break MongoDB."
|
||||
echo "If you choose yes, SELinux protection will be disabled. It is recommended to re-enable this afterwards with the following command:"
|
||||
echo "# setenforce 1"
|
||||
read -p "Disable SELinux? [y/N] " -n 1 -r
|
||||
echo
|
||||
if [[ "$REPLY" =~ ^[Yy]$ ]]; then
|
||||
sudo setenforce 0
|
||||
sleep 1
|
||||
else
|
||||
echo "Not disabling SELinux; You will most likely encounter permission errors."
|
||||
sleep 1
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! type "docker-compose" > /dev/null; then
|
||||
echo "Error: docker-compose is not installed!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -d .private/db ]]; then mkdir -p .private/db; fi
|
||||
|
||||
docker-compose --file docker-compose.dev.yml up --abort-on-container-exit
|
Loading…
Reference in New Issue