From f0a0b62eb3345516c227613222360048ae9a1af2 Mon Sep 17 00:00:00 2001 From: Blacky <77108939+brblacky@users.noreply.github.com> Date: Mon, 29 Jan 2024 14:02:44 +0530 Subject: [PATCH] Update file paths and dependencies --- .env.example | 4 --- .gitignore | 4 +-- Dockerfile | 2 +- ...pplication.yml => example.application.yml} | 0 README.md | 33 +++--------------- database/lavamusic.db | Bin 0 -> 69632 bytes docker-compose.yml | 17 +++++---- src/database/server.ts | 6 ++-- src/structures/Lavamusic.ts | 4 +-- 9 files changed, 21 insertions(+), 49 deletions(-) rename Lavalink/{application.yml => example.application.yml} (100%) create mode 100644 database/lavamusic.db diff --git a/.env.example b/.env.example index ffc9aed7c..8973c7229 100644 --- a/.env.example +++ b/.env.example @@ -4,10 +4,6 @@ PREFIX= "!" # Your prefix OWNER_IDS=["959276033683628122","859640640640640640"] # Your discord id, you can add multiple ids -CLIENT_ID= "960072976412340254" # Your bot client id - -CLIENT_SECRET= "" # Your bot client secret - GUILD_ID= "859640640640640640" # Your server Id if you want to use the for single server PRODUCTION="true" # true for production diff --git a/.gitignore b/.gitignore index 09c9b8c4a..14346e5c7 100644 --- a/.gitignore +++ b/.gitignore @@ -32,8 +32,6 @@ /package-lock.json -/Lavalink/dev.application.yml +/Lavalink/application.yml /Lavalink/plugins - -/src/database/* \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 36b8e3016..5a97177da 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,7 +24,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/src/database/lavamusic.db ./src/database/lavamusic.db +COPY --from=builder /opt/lavamusic/database/lavamusic.db ./database/lavamusic.db # Copy package files and install dependencies COPY package*.json ./ diff --git a/Lavalink/application.yml b/Lavalink/example.application.yml similarity index 100% rename from Lavalink/application.yml rename to Lavalink/example.application.yml diff --git a/README.md b/README.md index 33e691abc..d6f354c0a 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@

lavamusic

-

Lavamusic is a Discord music bot that uses Discord.js, Shoukaku, Prisma Client (ORM) database (MongoDB), and TypeScript. +

Lavamusic is a Discord music bot that uses Discord.js, Shoukaku, and TypeScript.

Invite Lavamusic @@ -111,7 +111,6 @@ Before starting with the installation, you need to have the following: - ![Node.js](https://img.shields.io/badge/Node.js-43853D?style=for-the-badge&logo=node.js&logoColor=white) [v18.17.1 or higher](https://nodejs.org/en/download/) -- ![MongoDB](https://img.shields.io/badge/MongoDB-4EA94B?style=for-the-badge&logo=mongodb&logoColor=white) [v4.4.0 or higher](https://www.mongodb.com/try/download/community) - ![Lavalink](https://img.shields.io/badge/Lavalink-7289DA?style=for-the-badge&logo=discord&logoColor=white) [v4.0.x or higher](https://github.com/freyacodes/Lavalink) ## 🚀 Installation from source @@ -143,7 +142,6 @@ or you can use the [.env.example](https://raw.githubusercontent.com/brblacky/lav TOKEN="." # Your bot token PREFIX= "!" # Your prefix OWNER_IDS=["859640640640640640","859640640640640640"] # Your discord id, you can add multiple ids -CLIENT_ID= "960072976412340254" # Your bot client id GUILD_ID= "859640640640640640" # Your server Id if you want to use the for single server PRODUCTION="true" # true for production SEARCH_ENGINE= "ytsearch" # ytsearch, scsearch or ytmsearch @@ -151,7 +149,6 @@ MAX_PLAYLIST_SIZE= "100" # Max playlist size MAX_QUEUE_SIZE= "100" # Max queue size BOT_STATUS= "online" # Your bot status BOT_ACTIVITY= "Wavemusic" # Your bot activity -DATABASE_URL="mongodb+srv://xxyydd:ejejeje@cluster0.f93tcdq.mongodb.net/Bot" ## Your MongoDB URL (add database name at the end) example: mongodb+srv://xxyydd:ejejeje@cluster0.f93tcdq.mongodb.net/Bot LAVALINK_URL="localhost:2333" # Your lavalink url LAVALINK_AUTH="youshallnotpass" # Your lavalink password LAVALINK_NAME="Blacky" # Your lavalink name @@ -161,32 +158,13 @@ BOT_ACTIVITY_TYPE=0 # Activity type is a number from 0 to 5 see more here https: ``` -5. Generate the Prisma client: - -**If you using replit than read this:** - -go to **[prisma/schema.prisma](https://github.com/brblacky/lavamusic/blob/main/prisma/schema.prisma)** and add engine type like this or remove `//` behind the `engineType` - -```bash -generator client { - provider = "prisma-client-js" - engineType = "binary" -} -``` - -and then run this command - -```bash -npx prisma generate -``` - -6. Run the bot: +5. Run the bot: ```bash -npm run start or npm start +npm start ``` -7. Invite the bot to your server: +6. Invite the bot to your server: Generate an invite link for your bot and invite it to your server using the Discord Developer Portal or using permissions calculator: @@ -205,7 +183,6 @@ your .env file should look like this or you can use the [.env.example](https://r TOKEN="." # Your bot token and remember, don't show everyone your bot token PREFIX="!" # Your prefix OWNER_IDS=["859640640640640640","859640640640640640"] # Your discord id, you can add multiple ids -CLIENT_ID="960072976412340254" # Your bot client ID GUILD_ID="859640640640640640" # Your server ID (if you want to use it for a single server) PRODUCTION="true" # "true" for production @@ -245,9 +222,7 @@ Do note that the bot will restart itself to update to the latest! - ![Node.js](https://img.shields.io/badge/Node.js-43853D?style=for-the-badge&logo=node.js&logoColor=white) [Node.js](https://nodejs.org/en/download/) - ![Discord.js](https://img.shields.io/badge/Discord.js-7289DA?style=for-the-badge&logo=discord&logoColor=white) [Discord.js](https://discord.js.org/#/) -- ![Prisma](https://img.shields.io/badge/Prisma-1B222D?style=for-the-badge&logo=prisma&logoColor=white) [Prisma](https://www.prisma.io/) - ![Lavalink](https://img.shields.io/badge/Lavalink-7289DA?style=for-the-badge&logo=discord&logoColor=white) [Lavalink](https://github.com/lavalink-devs/Lavalink) -- ![MongoDB](https://img.shields.io/badge/MongoDB-4EA94B?style=for-the-badge&logo=mongodb&logoColor=white) [MongoDB](https://www.mongodb.com/) - ![Docker](https://img.shields.io/badge/Docker-2496ED?style=for-the-badge&logo=docker&logoColor=white) [Docker](https://www.docker.com/) - ![Docker-Compose](https://img.shields.io/badge/Docker--Compose-2496ED?style=for-the-badge&logo=docker&logoColor=white) [Docker-Compose](https://docs.docker.com/compose/) diff --git a/database/lavamusic.db b/database/lavamusic.db new file mode 100644 index 0000000000000000000000000000000000000000..1d30bef80c1e384578abe5c9f4be47262588751e GIT binary patch literal 69632 zcmeI(?Qhyf9KdlK5);CM!wc#cQ6-~IYLVC!3nd6mn?^gdRm;{TLuxBcVh(mvGr$=( zXO`?zO*cl_X+&hZoT>+X|=c{cM# zPW(>&qaDrY?5c`4aoo$`=aKm1zHiS$U%u|gmG!MSQ?W}q!!Xo&O~w(p;p|*)%83|c zk$Ly}iIO3N?qwK9&@jht5ZGt#GNO7}Gd?v|MI@{4TXLuWSjZW*nmRAYXiofa@YJ46 z+|gC8n277D{C@^lZx%J<%i5}7uIlSsSNYPT?VNG@wmMfAoi(zbkGvo}kN1T{NXybh ze>KdBJ$7Z+HO#=DoCPvppI5hXMzyN`Qj#@CJshq1M2%5NqP8TxJs1e@p8u0OiBB+f zPp5A1^m>tfVTblKem|=4T0D*y45r@Lo7kbh_(=UuUNb(au2PDQ?_1G!`-_|w4IfX2 zKlMj$AU9iy2FRjh2Q|#7a5+N0+SH6nMSUr2afZ%NOC0YElLsf;KlUBhy!Y_oVYl;b z{R2%iT9s9SJHx)^40AtZCHj06IA>IH(^(S({=)YL|25{$#!Yrny<)VB z?dFlXxbzmIN?u!XlSu?3i*AZUT*;^2(R{q`le}4bJ_8m(D5I_I{1Q0*~0R#|0 l009ILc&`Az|9>wLA3y*B1Q0*~0R#|0009ILKw#|!{ssHpn^XV* literal 0 HcmV?d00001 diff --git a/docker-compose.yml b/docker-compose.yml index b2eb7d034..faabf7495 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -16,10 +16,16 @@ services: #ports: # you only need this if you want to make your lavalink accessible from outside of containers #- "2333:2333" + healthcheck: + test: "curl -H \"Authorization: youshallnotpass\" -s http://localhost:2333/version" + interval: 10s + timeout: 10s + retries: 5 + start_period: 10s lavamusic: container_name: lavamusic - image: ghcr.io/brblacky/lavamusic:main + image: lavamusic:latest environment: # Your mongodb url - LAVALINK_URL=lavalink:2333 @@ -33,11 +39,8 @@ services: volumes: # mount .env from the same directory or use environment variables - .env:/opt/lavamusic/.env - - ./src/database/lavamusic.db:/opt/lavamusic/src/database/lavamusic.db - - command: bash -c "apt-get update -y && apt-get install -y openssl && npx prisma generate && node dist/index.js" + - ./database:/opt/lavamusic/database restart: on-failure depends_on: - - lavalink -volumes: - mongodb_data: \ No newline at end of file + lavalink: + condition: service_healthy \ No newline at end of file diff --git a/src/database/server.ts b/src/database/server.ts index 305d869ec..775858fe7 100644 --- a/src/database/server.ts +++ b/src/database/server.ts @@ -2,7 +2,7 @@ import Database from 'better-sqlite3'; import config from '../config.js'; -const db = new Database('./src/database/lavamusic.db', { +const db = new Database('./database/lavamusic.db', { fileMustExist: false, readonly: false }); @@ -70,9 +70,9 @@ export default class ServerData { public getPrefix(guildId: string): any { const data: any = db.prepare('SELECT * FROM guild WHERE guildId = ?').get(guildId); if (!data) { - db.prepare('INSERT INTO guild (guildId) VALUES (?)').run(guildId); + db.prepare('INSERT INTO guild (guildId, prefix) VALUES (?, ?)').run(guildId, config.prefix); return { - prefix: config.prefix + prefix: config.prefix, }; } else { return data; diff --git a/src/structures/Lavamusic.ts b/src/structures/Lavamusic.ts index 2ba5bab39..97413f776 100644 --- a/src/structures/Lavamusic.ts +++ b/src/structures/Lavamusic.ts @@ -115,9 +115,9 @@ export default class Lavamusic extends Client { this.once('ready', async () => { const applicationCommands = this.config.production === true - ? Routes.applicationCommands(this.config.clientId ?? '') + ? Routes.applicationCommands(this.user.id ?? '') : Routes.applicationGuildCommands( - this.config.clientId ?? '', + this.user.id ?? '', this.config.guildId ?? '' ); try {