From 051a23132c165fc9295560cdfff691f05e4e6323 Mon Sep 17 00:00:00 2001 From: brblacky Date: Sun, 14 Apr 2024 11:15:57 +0530 Subject: [PATCH] Update Dockerfile and package.json, and fix bugs in Prefix.ts and docker-compose.yml --- Dockerfile | 9 +++++--- docker-compose.yml | 39 ++++++++++++++++++++++++++++++++++- package.json | 5 ++--- src/commands/config/Prefix.ts | 8 +++---- src/commands/info/Help.ts | 10 ++++----- 5 files changed, 55 insertions(+), 16 deletions(-) diff --git a/Dockerfile b/Dockerfile index 68f8ba8d6..f25bfd370 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ WORKDIR /opt/lavamusic/ # Copy package files and install dependencies COPY package*.json ./ RUN apt-get update && \ - apt-get install -y && \ + apt-get install -y openssl && \ npm install # Copy source code @@ -14,7 +14,10 @@ COPY . . # Copy tsconfig.json COPY tsconfig.json ./ - +# Copy prisma +COPY prisma ./prisma +# Generate Prisma client +RUN npx prisma generate # Build TypeScript RUN npm run build @@ -28,7 +31,7 @@ WORKDIR /opt/lavamusic/ # Copy compiled code COPY --from=builder /opt/lavamusic/dist ./dist COPY --from=builder /opt/lavamusic/src/utils/LavaLogo.txt ./src/utils/LavaLogo.txt - +COPY --from=builder /opt/lavamusic/prisma ./prisma # Copy package files and install production dependencies COPY package*.json ./ RUN npm install --only=production diff --git a/docker-compose.yml b/docker-compose.yml index 190bfa710..8995f2403 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,5 @@ services: + ## services for lavalink lavalink: container_name: lavamusic-lavalink image: ghcr.io/lavalink-devs/lavalink @@ -23,7 +24,39 @@ services: timeout: 10s retries: 5 start_period: 10s + # services for postgresql database + # postgres: + # container_name: lavamusic-postgres + # image: postgres:16 + # restart: on-failure + # environment: + # POSTGRES_USER: lavamusic + # POSTGRES_PASSWORD: lavamusic + # POSTGRES_DB: lavamusic + # + # volumes: + # - ./Postgres/data:/var/lib/postgresql/data + # healthcheck: + # test: 'pg_isready -U lavamusic' + # interval: 10s + # timeout: 10s + # retries: 5 + # start_period: 10s + # services for mongodb database + #mongodb: + #container_name: lavamusic-mongodb + #image: 'bitnami/mongodb:4.4' + #restart: on-failure + #environment: + #MONGODB_ADVERTISED_HOSTNAME: 127.0.0.1 + #MONGODB_REPLICA_SET_MODE: primary + #MONGODB_ROOT_USER: mongoadmin + #MONGODB_ROOT_PASSWORD: mongopassword + #MONGODB_REPLICA_SET_KEY: replicasetkey123 + #volumes: - ./MongoDB/data:/data/db + + # services for lavamusic lavamusic: container_name: lavamusic image: ghcr.io/appujet/lavamusic:main @@ -36,7 +69,11 @@ services: - LAVALINK_NAME=Blacky' # Your lavalink secure (true or false) - LAVALINK_SECURE=false - + # database url + # - DATABASE_URL= put your database url here (mongodb or postgres) + # - DATABASE_URL=postgresql://lavamusic:lavamusic@postgres:5432/lavamusic (for postgres) + # - DATABASE_URL=mongodb://mongoadmin:mongopassword@mongodb:27017/lavamusic?authSource=admin (for mongodb) + volumes: # mount .env from the same directory or use environment variables - .env:/opt/lavamusic/.env diff --git a/package.json b/package.json index 6ff421d36..e3bb819df 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,6 @@ "scripts": { "start": "npm run build && node dist/index.js", "prisma:generate": "npx prisma generate", - "prisma:migrate": "npx prisma migrate dev --name init", "build": "tsc --project tsconfig.json", "clean": "rm -rf dist", "lint": "eslint . --cache --ext .js,.jsx,.ts,.tsx", @@ -41,7 +40,7 @@ "@types/signale": "^1.4.7", "@typescript-eslint/eslint-plugin": "^7.6.0", "@typescript-eslint/parser": "^7.6.0", - "eslint": "^8.56.0", + "eslint": "^9.0.0", "eslint-plugin-import": "^2.29.1", "eslint-plugin-unicorn": "^52.0.0", "prettier": "^3.2.5", @@ -67,4 +66,4 @@ "displayTimestamp": true, "underlineLabel": true } -} +} \ No newline at end of file diff --git a/src/commands/config/Prefix.ts b/src/commands/config/Prefix.ts index 1e908e6bc..93e144e33 100644 --- a/src/commands/config/Prefix.ts +++ b/src/commands/config/Prefix.ts @@ -49,7 +49,7 @@ export default class Prefix extends Command { } public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { const embed = client.embed().setColor(client.color.main); - let prefix = await client.db.getPrefix(ctx.guild.id); + let guild = await client.db.get(ctx.guild.id); let subCommand: string; let pre: string; @@ -64,7 +64,7 @@ export default class Prefix extends Command { case 'set': if (!pre) { embed.setDescription( - `The prefix for this server is \`${prefix ? prefix.prefix : client.config.prefix + `The prefix for this server is \`${guild ? guild.prefix : client.config.prefix }\`` ); return await ctx.sendMessage({ embeds: [embed] }); @@ -76,7 +76,7 @@ export default class Prefix extends Command { ], }); - if (!prefix) { + if (!guild) { client.db.setPrefix(ctx.guild.id, pre); return await ctx.sendMessage({ embeds: [ @@ -92,7 +92,7 @@ export default class Prefix extends Command { }); } case 'reset': - if (!prefix) + if (!guild) return await ctx.sendMessage({ embeds: [ embed.setDescription( diff --git a/src/commands/info/Help.ts b/src/commands/info/Help.ts index 32c187490..540d4171a 100644 --- a/src/commands/info/Help.ts +++ b/src/commands/info/Help.ts @@ -37,7 +37,7 @@ export default class Help extends Command { } public async run(client: Lavamusic, ctx: Context, args: string[]): Promise { const embed = client.embed(); - const prefix = await client.db.getPrefix(ctx.guild.id); + const guild = await client.db.get(ctx.guild.id); const commands = this.client.commands.filter(cmd => cmd.category !== 'dev'); const categories = commands .map(cmd => cmd.category) @@ -59,10 +59,10 @@ export default class Help extends Command { .setColor(this.client.color.main) .setTitle('Help Menu') .setDescription( - `Hey there! I'm ${this.client.user.username}, a music bot made with [Lavamusic](https://github.com/appujet/lavamusic) and Discord. You can use \`${prefix.prefix}help \` to get more info on a command.` + `Hey there! I'm ${this.client.user.username}, a music bot made with [Lavamusic](https://github.com/appujet/lavamusic) and Discord. You can use \`${guild.prefix}help \` to get more info on a command.` ) .setFooter({ - text: `Use ${prefix.prefix}help for more info on a command`, + text: `Use ${guild.prefix}help for more info on a command`, }); fildes.forEach(field => helpEmbed.addFields(field)); ctx.sendMessage({ embeds: [helpEmbed] }); @@ -82,8 +82,8 @@ export default class Help extends Command { .setColor(this.client.color.main) .setTitle(`Help Menu - ${command.name}`).setDescription(`**Description:** ${command.description.content } -**Usage:** ${prefix.prefix}${command.description.usage} -**Examples:** ${command.description.examples.map(example => `${prefix.prefix}${example}`).join(', ')} +**Usage:** ${guild.prefix}${command.description.usage} +**Examples:** ${command.description.examples.map(example => `${guild.prefix}${example}`).join(', ')} **Aliases:** ${command.aliases.map(alias => `\`${alias}\``).join(', ')} **Category:** ${command.category} **Cooldown:** ${command.cooldown} seconds