From 9cc8dfd61ed2897f469b051f0913b00fea5a3106 Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Sat, 6 Apr 2024 14:29:23 +0300 Subject: [PATCH] Fix missing ready event emit, add yarn commands, fix client path --- .gitignore | 3 +++ Dockerfile | 20 ++++++++++++++++++++ package.json | 4 ++++ src/client/Client.ts | 1 + src/middleware/Controller.ts | 2 +- 5 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 Dockerfile diff --git a/.gitignore b/.gitignore index ceaea36..761c969 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,9 @@ bower_components # node-waf configuration .lock-wscript +# Ignore whole build directory +build + # Compiled binary addons (https://nodejs.org/api/addons.html) build/Release diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..77e21f1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,20 @@ +# Template Dockerfile, expand as necessary + +FROM node:lts-alpine as builder + +# For C/C++ dependencies that need to be built +RUN apk update && apk add build-base python3 +WORKDIR /app +COPY package.json package.json +COPY ./.yarnrc.yml ./.yarnrc.yml +COPY ./.yarn/releases ./.yarn/releases +RUN yarn install + +FROM node:lts-alpine +WORKDIR /app +COPY build build +COPY --from=builder /musicbot/node_modules ./node_modules +COPY package.json package.json +# VOLUME [ "/app/cache" ] +CMD ["node", "--enable-source-maps", "build/index.js"] +# CMD ["/bin/ash"] \ No newline at end of file diff --git a/package.json b/package.json index b9dce07..6ae1dc2 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,10 @@ "license": "MIT", "packageManager": "yarn@4.1.1", "type": "module", + "scripts": { + "build": "tsc --build", + "start": "yarn build && node --enable-source-maps build/index.js --shards 1 --respawn false" + }, "dependencies": { "@navy.gif/commandparser": "^1.7.4", "@navy.gif/logger": "^2.5.4", diff --git a/src/client/Client.ts b/src/client/Client.ts index f5563d2..1909d1f 100644 --- a/src/client/Client.ts +++ b/src/client/Client.ts @@ -61,6 +61,7 @@ class Client extends EventEmitter // this.#logger.info('Logging in'); const ready = this.#ready(); // await super.login(); + this.emit('ready'); // the ready waiter expects a ready event from the superclass, in our case that doesn't happen so we emit it ourselves await ready; this.#built = true; diff --git a/src/middleware/Controller.ts b/src/middleware/Controller.ts index 0b88321..f0c1080 100644 --- a/src/middleware/Controller.ts +++ b/src/middleware/Controller.ts @@ -21,7 +21,7 @@ class Controller constructor (options: ControllerOptions, version: string) { - const clientPath = path.join(options.rootDir, 'client/DiscordClient.js'); + const clientPath = path.join(options.rootDir, 'client/Client.js'); if (!fs.existsSync(clientPath)) throw new Error(`Client path does not seem to exist: ${clientPath}`);