Fix missing ready event emit, add yarn commands, fix client path

This commit is contained in:
Erik 2024-04-06 14:29:23 +03:00
parent dd5360adcd
commit 9cc8dfd61e
5 changed files with 29 additions and 1 deletions

3
.gitignore vendored
View File

@ -36,6 +36,9 @@ bower_components
# node-waf configuration # node-waf configuration
.lock-wscript .lock-wscript
# Ignore whole build directory
build
# Compiled binary addons (https://nodejs.org/api/addons.html) # Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release build/Release

20
Dockerfile Normal file
View File

@ -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"]

View File

@ -8,6 +8,10 @@
"license": "MIT", "license": "MIT",
"packageManager": "yarn@4.1.1", "packageManager": "yarn@4.1.1",
"type": "module", "type": "module",
"scripts": {
"build": "tsc --build",
"start": "yarn build && node --enable-source-maps build/index.js --shards 1 --respawn false"
},
"dependencies": { "dependencies": {
"@navy.gif/commandparser": "^1.7.4", "@navy.gif/commandparser": "^1.7.4",
"@navy.gif/logger": "^2.5.4", "@navy.gif/logger": "^2.5.4",

View File

@ -61,6 +61,7 @@ class Client extends EventEmitter
// this.#logger.info('Logging in'); // this.#logger.info('Logging in');
const ready = this.#ready(); const ready = this.#ready();
// await super.login(); // 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; await ready;
this.#built = true; this.#built = true;

View File

@ -21,7 +21,7 @@ class Controller
constructor (options: ControllerOptions, version: string) 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)) if (!fs.existsSync(clientPath))
throw new Error(`Client path does not seem to exist: ${clientPath}`); throw new Error(`Client path does not seem to exist: ${clientPath}`);