Skip to content

Commit

Permalink
Update Dockerfile and package.json, and fix bugs in Prefix.ts and doc…
Browse files Browse the repository at this point in the history
…ker-compose.yml
  • Loading branch information
appujet committed Apr 14, 2024
1 parent de5ce80 commit 051a231
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 16 deletions.
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@ 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
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

Expand All @@ -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
Expand Down
39 changes: 38 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
services:
## services for lavalink
lavalink:
container_name: lavamusic-lavalink
image: ghcr.io/lavalink-devs/lavalink
Expand All @@ -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
Expand All @@ -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
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -67,4 +66,4 @@
"displayTimestamp": true,
"underlineLabel": true
}
}
}
8 changes: 4 additions & 4 deletions src/commands/config/Prefix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default class Prefix extends Command {
}
public async run(client: Lavamusic, ctx: Context, args: string[]): Promise<any> {
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;
Expand All @@ -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] });
Expand All @@ -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: [
Expand All @@ -92,7 +92,7 @@ export default class Prefix extends Command {
});
}
case 'reset':
if (!prefix)
if (!guild)
return await ctx.sendMessage({
embeds: [
embed.setDescription(
Expand Down
10 changes: 5 additions & 5 deletions src/commands/info/Help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default class Help extends Command {
}
public async run(client: Lavamusic, ctx: Context, args: string[]): Promise<any> {
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)
Expand All @@ -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 <command>\` 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 <command>\` to get more info on a command.`
)
.setFooter({
text: `Use ${prefix.prefix}help <command> for more info on a command`,
text: `Use ${guild.prefix}help <command> for more info on a command`,
});
fildes.forEach(field => helpEmbed.addFields(field));
ctx.sendMessage({ embeds: [helpEmbed] });
Expand All @@ -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
Expand Down

0 comments on commit 051a231

Please sign in to comment.