diff --git a/.env.example b/.env.example index bc28d04..8fe62fb 100644 --- a/.env.example +++ b/.env.example @@ -3,17 +3,10 @@ TOKEN=YOURTOKENHERE # List of admins who can use the bot commands using discord user id's. # You can add multiple by adding a space between the id's. -ADMINS=1234 +ADMINS=ID ID ID -# The general chat id that the bot will use for the scheduled messages. -CHANNEL_ID=YOURCHANNELIDHERE +# The channel that the bot will use for the scheduled messages. +CHANNEL_ID=ID -# Must be a number -SHARDS=1 - -# Here is your Postgres login configuration -POSTGRES_HOST=127.0.0.1 -POSTGRES_USERNAME=postgres -POSTGRES_PASSWORD=password -POSTGRES_PORT=5432 -POSTGRES_DATABASE=crystalbot +# The amount of shards that will be created. +SHARDS=1 \ No newline at end of file diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 11aa552..8ddbf80 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -2,9 +2,9 @@ name: Docker Image CI on: push: - branches: [ "master" ] + branches: [ "master", "dev" ] pull_request: - branches: [ "master" ] + branches: [ "master", "dev" ] jobs: diff --git a/docker-compose-example.yml b/docker-compose-example.yml index 47c3bb3..3802cfb 100644 --- a/docker-compose-example.yml +++ b/docker-compose-example.yml @@ -7,12 +7,6 @@ services: context: . environment: - TOKEN=YOURTOKENHERE - - PREFIX=. - ADMINS=1234 - SHARDS=1 - CHANNEL_ID=YOURCHANNELIDHERE - - POSTGRES_HOST=127.0.0.1 - - POSTGRES_USERNAME=postgres - - POSTGRES_PASSWORD=password - - POSTGRES_PORT=5432 - - POSTGRES_DATABASE=crystalbot diff --git a/src/index.ts b/src/index.ts index d19338a..4a8e032 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,7 +5,7 @@ const config = getConfig() const manager = new ShardingManager("./bot.js", { totalShards: config.shards, token: `${config.token}` }) manager.on("shardCreate", shard => { - console.log(`Launched shard ${shard.id}`) + console.log(`Launched shard ${shard.id + 1}`) }) process.on("unhandledRejection", err => { diff --git a/src/modules/config.ts b/src/modules/config.ts index 30ae327..c6ce206 100644 --- a/src/modules/config.ts +++ b/src/modules/config.ts @@ -9,12 +9,5 @@ export function getConfig(): Config { admins: process.env.ADMINS != null ? process.env.ADMINS.split(" ") : [], channelId: `${process.env.CHANNEL_ID}`, shards: process.env.SHARDS != null ? parseInt(process.env.SHARDS) : 1, - postgresConfig: { - host: `${process.env.POSTGRES_HOST}`, - username: `${process.env.POSTGRES_USERNAME}`, - password: `${process.env.POSTGRES_PASSWORD}`, - port: process.env.POSTGRES_PORT != null ? parseInt(process.env.POSTGRES_PORT) : 5432, - database: `${process.env.POSTGRES_DATABASE}`, - }, } } diff --git a/src/modules/database.ts b/src/modules/database.ts deleted file mode 100644 index 0c06572..0000000 --- a/src/modules/database.ts +++ /dev/null @@ -1,33 +0,0 @@ -// PostgreSQL database connection. -// https://www.npmjs.com/package/postgres -import { Pool } from "pg" -import { getConfig } from "./config" - -const config = getConfig() -const pool = new Pool({ - user: `${config.postgresConfig.username}`, - host: `${config.postgresConfig.host}`, - database: `${config.postgresConfig.database}`, - password: `${config.postgresConfig.password}`, - port: config.postgresConfig.port ?? 5432, -}) - -pool.on("error", (err, client) => { - console.error("Unexpected error on idle client", err) - process.exit(-1) -}) - -// This is where clients would connect -// To query the DB, a client must first be connected using the pool already defined above -// Then run the query, process the results, and finally release the client -// Top-level await isn't allowed in es2016, but *is* in 2017 or 2022. We may switch to that -/* -async function main() { - const client = await pool.connect() - const res = await client.query('SELECT NOW()'); - console.log(res.rows[0]) - client.release() -} - -main() -*/ diff --git a/src/types/Config.ts b/src/types/Config.ts index d6f24f7..fa88219 100644 --- a/src/types/Config.ts +++ b/src/types/Config.ts @@ -3,13 +3,4 @@ export type Config = { admins: string[] channelId: string shards: number - postgresConfig: PostgresConfig -} - -export type PostgresConfig = { - host: string - username: string - password: string - port: number - database: string -} +} \ No newline at end of file