Skip to content

Commit

Permalink
new
Browse files Browse the repository at this point in the history
  • Loading branch information
appujet committed Aug 26, 2023
1 parent b6a49f1 commit eb947cd
Show file tree
Hide file tree
Showing 7 changed files with 165 additions and 113 deletions.
48 changes: 24 additions & 24 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "lavamusic",
"version": "3.2.0",
"version": "3.3.0",
"description": "LavaMusic is a music bot for Discord, written in JavaScript using the Discord.js, Typescript, Shoukaku (Lavalink) library.",
"type": "module",
"main": "dist/index.js",
"scripts": {
"start": "npm run prisma:generate && npm run start:bot",
"start": "npm run start:bot",
"prisma:generate": "npx prisma generate",
"start:bot": "npm run build && node --enable-source-maps dist/index.js",
"build": "tsc --project tsconfig.json"
Expand All @@ -31,14 +31,14 @@
},
"homepage": "https://github.com/brblacky/lavamusic#readme",
"devDependencies": {
"@types/node": "^20.5.1",
"@types/node": "^20.5.6",
"@types/signale": "^1.4.4",
"prisma": "^5.1.1",
"prisma": "^5.2.0",
"ts-node": "^10.9.1",
"typescript": "^5.1.6"
"typescript": "^5.2.2"
},
"dependencies": {
"@prisma/client": "^5.1.1",
"@prisma/client": "^5.2.0",
"discord.js": "^14.13.0",
"dotenv": "^16.3.1",
"shoukaku": "^3.4.0",
Expand Down
13 changes: 0 additions & 13 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ model Guild {
dj Dj?
botchannel Botchannel?
premium Premium?
tracks Tracks[]
}

model Setup {
Expand Down Expand Up @@ -96,15 +95,3 @@ model Premium {
user User? @relation(fields: [userId], references: [userId])
guild Guild? @relation(fields: [guildId], references: [guildId])
}

model Tracks {
id String @id @default(auto()) @map("_id") @db.ObjectId
trackId String @unique
title String
url String
duration String
thumbnail String
played Int @default(0)
guildId String
guild Guild? @relation(fields: [guildId], references: [guildId])
}
10 changes: 2 additions & 8 deletions src/commands/config/247.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Command, Lavamusic, Context } from '../../structures/index.js';
import ServerData from '../../database/server.js';

export default class _247 extends Command {
constructor(client: Lavamusic) {
Expand Down Expand Up @@ -39,13 +40,7 @@ export default class _247 extends Command {
});
const vc = ctx.member as any;
if (!data) {
await client.prisma.stay.create({
data: {
guildId: ctx.guild.id,
textId: ctx.channel.id,
voiceId: vc.voice.channelId,
},
});
await ServerData.set_247(ctx.guild.id, ctx.channel.id, vc.voice.channelId);
if (!player)
player = await client.queue.create(ctx.guild, vc.voice.channel, ctx.channel, client.shoukaku.getNode());
return ctx.sendMessage({
Expand All @@ -57,7 +52,6 @@ export default class _247 extends Command {
guildId: ctx.guild.id,
},
});

return ctx.sendMessage({
embeds: [embed.setDescription(`**247 mode has been disabled**`).setColor(client.color.red)],
});
Expand Down
39 changes: 4 additions & 35 deletions src/commands/config/Dj.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Command, Lavamusic, Context } from '../../structures/index.js';
import { ApplicationCommandOptionType } from 'discord.js';
import ServerData from '../../database/server.js';

export default class Dj extends Command {
constructor(client: Lavamusic) {
Expand Down Expand Up @@ -96,34 +97,12 @@ export default class Dj extends Command {
});

if (!dj) {
await this.client.prisma.dj.create({
data: {
guildId: ctx.guild.id,
roles: {
create: {
roleId: role.id,
},
},
mode: true,
},
});
await ServerData.setDj(ctx.guild.id, role.id);
return await ctx.sendMessage({
embeds: [embed.setDescription(`The dj role <@&${role.id}> has been added`)],
});
} else {
await this.client.prisma.dj.update({
where: {
guildId: ctx.guild.id,
},
data: {
mode: true,
roles: {
create: {
roleId: role.id,
},
},
},
});
await ServerData.setDj(ctx.guild.id, role.id);
return await ctx.sendMessage({
embeds: [embed.setDescription(`The dj role <@&${role.id}> has been added`)],
});
Expand All @@ -149,17 +128,7 @@ export default class Dj extends Command {
return await ctx.sendMessage({
embeds: [embed.setDescription('There are no dj roles to clear')],
});
await this.client.prisma.roles.deleteMany({
where: { guildId: ctx.guild.id },
});
await this.client.prisma.dj.update({
where: {
guildId: ctx.guild.id,
},
data: {
mode: false,
},
});
await ServerData.setDj(ctx.guild.id);
return await ctx.sendMessage({
embeds: [embed.setDescription(`All dj roles have been removed`)],
});
Expand Down
35 changes: 8 additions & 27 deletions src/commands/config/Prefix.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Command, Lavamusic, Context } from '../../structures/index.js';
import ServerData from '../../database/server.js';

export default class Prefix extends Command {
constructor(client: Lavamusic) {
Expand Down Expand Up @@ -49,11 +50,7 @@ export default class Prefix extends Command {
}
public async run(client: Lavamusic, ctx: Context, args: string[]): Promise<void> {
const embed = client.embed().setColor(client.color.main);
let prefix = (await this.client.prisma.guild.findUnique({
where: {
guildId: ctx.guild.id,
},
})) as any;
let prefix = await ServerData.get(ctx.guild.id);

let subCommand: string;
let pre: string;
Expand All @@ -76,24 +73,14 @@ export default class Prefix extends Command {
});

if (!prefix) {
prefix = await this.client.prisma.guild.create({
data: {
guildId: ctx.guild.id,
prefix: pre,
},
});
await ServerData.setPrefix(ctx.guild.id, pre);
prefix = await ServerData.get(ctx.guild.id);
return await ctx.sendMessage({
embeds: [embed.setDescription(`The prefix for this server is now \`${prefix.prefix}\``)],
});
} else {
prefix = await this.client.prisma.guild.update({
where: {
guildId: ctx.guild.id,
},
data: {
prefix: pre,
},
});
await ServerData.setPrefix(ctx.guild.id, pre);
prefix = await ServerData.get(ctx.guild.id);
return await ctx.sendMessage({
embeds: [embed.setDescription(`The prefix for this server is now \`${prefix.prefix}\``)],
});
Expand All @@ -103,14 +90,8 @@ export default class Prefix extends Command {
return await ctx.sendMessage({
embeds: [embed.setDescription(`The prefix for this server is \`${client.config.prefix}\``)],
});
prefix = await this.client.prisma.guild.update({
where: {
guildId: ctx.guild.id,
},
data: {
prefix: client.config.prefix,
},
});
await ServerData.setPrefix(ctx.guild.id, client.config.prefix);
prefix = await ServerData.get(ctx.guild.id);
return await ctx.sendMessage({
embeds: [embed.setDescription(`The prefix for this server is now \`${client.config.prefix}\``)],
});
Expand Down
Loading

0 comments on commit eb947cd

Please sign in to comment.