Skip to content

Commit

Permalink
Update file paths and dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
appujet committed Jan 29, 2024
1 parent 3eabb31 commit f0a0b62
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 49 deletions.
4 changes: 0 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@

/package-lock.json

/Lavalink/dev.application.yml
/Lavalink/application.yml

/Lavalink/plugins

/src/database/*
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ./
Expand Down
File renamed without changes.
33 changes: 4 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

<h1 align="center">lavamusic</h1>

<p align="center">Lavamusic is a Discord music bot that uses Discord.js, Shoukaku, Prisma Client (ORM) database (MongoDB), and TypeScript.
<p align="center">Lavamusic is a Discord music bot that uses Discord.js, Shoukaku, and TypeScript.
<br />
<br />
<a href="https://discord.com/api/oauth2/authorize?client_id=875635121770889257&permissions=8&scope=bot%20applications.commands">Invite Lavamusic</a>
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -143,15 +142,13 @@ 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
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:[email protected]/Bot" ## Your MongoDB URL (add database name at the end) example: mongodb+srv://xxyydd:[email protected]/Bot
LAVALINK_URL="localhost:2333" # Your lavalink url
LAVALINK_AUTH="youshallnotpass" # Your lavalink password
LAVALINK_NAME="Blacky" # Your lavalink name
Expand All @@ -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: <https://discordapi.com/permissions.html>

Expand All @@ -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

Expand Down Expand Up @@ -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/)

Expand Down
Binary file added database/lavamusic.db
Binary file not shown.
17 changes: 10 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
lavalink:
condition: service_healthy
6 changes: 3 additions & 3 deletions src/database/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/structures/Lavamusic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit f0a0b62

Please sign in to comment.