From 082bfe6097e78b69cc8d501fdd352423491efe96 Mon Sep 17 00:00:00 2001 From: Lukas | AstroGD Date: Thu, 24 Nov 2022 12:12:50 +0100 Subject: [PATCH] logchannel command --- docker-compose.yml | 6 +++--- index.ts | 5 ++++- package-lock.json | 16 ++++++++++++++++ package.json | 1 + src/client/index.ts | 13 +------------ src/client/init.ts | 10 ++++++++++ src/data/dataSource.ts | 2 ++ tsconfig.json | 2 +- 8 files changed, 38 insertions(+), 17 deletions(-) create mode 100644 src/client/init.ts diff --git a/docker-compose.yml b/docker-compose.yml index 263a65c..60319fa 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,16 +5,16 @@ services: build: ./ depends_on: - database - restart: always + restart: unless-stopped environment: - TOKEN=$TOKEN - - DB_HOST=database:5432 + - DB_HOST=database - DB_USERNAME=$DB_USERNAME - DB_PASSWORD=$DB_PASSWORD - DB_DATABASE=$DB_DATABASE database: image: postgres:latest - restart: always + restart: unless-stopped ports: - 5432:5432 environment: diff --git a/index.ts b/index.ts index 0929e98..ce68056 100644 --- a/index.ts +++ b/index.ts @@ -4,10 +4,13 @@ import swapConsole from "./src/tools/consoleSwapper"; config(); swapConsole(); -import "./src/client"; +import "./src/client/init"; +import "./src/commands"; +import client from "./src/client"; function shutdown() { console.log("Shutdown request received"); + if (client) client.destroy(); process.exit(); } diff --git a/package-lock.json b/package-lock.json index c0f745d..f088f63 100644 --- a/package-lock.json +++ b/package-lock.json @@ -18,6 +18,7 @@ "devDependencies": { "@types/fs-extra": "^9.0.13", "@types/node": "^18.11.9", + "rimraf": "^3.0.2", "shx": "^0.3.4", "ts-node": "^10.9.1", "typescript": "^4.9.3" @@ -1029,6 +1030,21 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", diff --git a/package.json b/package.json index 2b75eb6..1be8d2e 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "devDependencies": { "@types/fs-extra": "^9.0.13", "@types/node": "^18.11.9", + "rimraf": "^3.0.2", "shx": "^0.3.4", "ts-node": "^10.9.1", "typescript": "^4.9.3" diff --git a/src/client/index.ts b/src/client/index.ts index 52ad420..c8aa925 100644 --- a/src/client/index.ts +++ b/src/client/index.ts @@ -6,15 +6,4 @@ const client = new Client({ ] }); -const token = process.env["TOKEN"]; -if (!token) throw new ReferenceError("TOKEN environment variable is missing"); - -client.login(token); - -client.on("ready", () => { - console.log(`Connected to Discord API. Bot account is ${client.user?.tag} (${client.user?.id})`); -}); - -export default client; - -import "../commands"; \ No newline at end of file +export default client; \ No newline at end of file diff --git a/src/client/init.ts b/src/client/init.ts new file mode 100644 index 0000000..bfa5e6e --- /dev/null +++ b/src/client/init.ts @@ -0,0 +1,10 @@ +import client from "./index"; + +const token = process.env["TOKEN"]; +if (!token) throw new ReferenceError("TOKEN environment variable is missing"); + +client.login(token); + +client.on("ready", () => { + console.log(`Connected to Discord API. Bot account is ${client.user?.tag} (${client.user?.id})`); +}); \ No newline at end of file diff --git a/src/data/dataSource.ts b/src/data/dataSource.ts index c7613f1..4dde07a 100644 --- a/src/data/dataSource.ts +++ b/src/data/dataSource.ts @@ -28,4 +28,6 @@ const dataSource = new DataSource({ migrationsTransactionMode: "each" }); +dataSource.initialize(); + export default dataSource; \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 1d6a364..dacf7c4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -15,7 +15,7 @@ // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ // "jsx": "preserve", /* Specify what JSX code is generated. */ "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ - "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */