Skip to content

Commit

Permalink
v4.3.2
Browse files Browse the repository at this point in the history
- correction and optimization of all remaining orders
  • Loading branch information
LucasB25 committed May 30, 2024
1 parent 0e69e3c commit 9c0a6c7
Show file tree
Hide file tree
Showing 27 changed files with 207 additions and 211 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
[LavaSrc]: https://github.com/TopiSenpai/LavaSrc
[skybot-lavalink-plugin]: https://github.com/DuncteBot/skybot-lavalink-plugin

### To set up a Lavalink server on Windows, Linux, or Replit, [Click Here.](https://github.com/LucasB25/lavalink-server)
### To Setup a Lavalink server on Windows, Linux, or Replit, [Click Here.](https://github.com/LucasB25/lavalink-server)

### **Need Help with plugins?** Join our [Discord Server](https://discord.gg/YsJCtDuTXp) and ask for help in the `#support` channel.

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lavamusic",
"version": "4.3.1",
"version": "4.3.2",
"description": "LavaMusic is a music bot for Discord, written in JavaScript using the Discord.js, Typescript, Shoukaku (Lavalink) library.",
"main": "dist/index.js",
"type": "module",
Expand Down
2 changes: 2 additions & 0 deletions src/commands/config/Dj.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//TODO

import { Command, Context, Lavamusic } from '../../structures/index.js';

export default class Dj extends Command {
Expand Down
11 changes: 6 additions & 5 deletions src/commands/music/Autoplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ export default class Autoplay extends Command {
const embed = this.client.embed();

const autoplay = player.autoplay;
player.setAutoplay(!autoplay);

if (!autoplay) {
embed.setDescription(`Autoplay has been enabled`).setColor(client.color.main);
player.setAutoplay(true);
embed.setDescription(`Autoplay has been enabled`).setColor(this.client.color.main);
} else {
embed.setDescription(`Autoplay has been disabled`).setColor(client.color.main);
player.setAutoplay(false);
embed.setDescription(`Autoplay has been disabled`).setColor(this.client.color.main);
}
ctx.sendMessage({ embeds: [embed] });

await ctx.sendMessage({ embeds: [embed] });
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/commands/music/ClearQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,17 @@ export default class ClearQueue extends Command {
public async run(client: Lavamusic, ctx: Context): Promise<any> {
const player = client.queue.get(ctx.guild.id);
const embed = this.client.embed();
if (!player.queue.length)

if (player.queue.length === 0) {
return await ctx.sendMessage({
embeds: [
embed
.setColor(this.client.color.red)
.setDescription('There are no songs in the queue.'),
],
});
}

player.queue = [];

return await ctx.sendMessage({
Expand Down
28 changes: 15 additions & 13 deletions src/commands/music/Grab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,34 +29,36 @@ export default class Grab extends Command {
});
}
public async run(client: Lavamusic, ctx: Context): Promise<any> {
const embed = client.embed().setColor(client.color.main);
let player = client.queue.get(ctx.guild.id);
let song = player.current;
const embed = this.client.embed().setColor(this.client.color.main);
const player = client.queue.get(ctx.guild.id);

const song = player.current;

try {
const dm = client
const dm = this.client
.embed()
.setTitle(`**${song.info.title}**`)
.setURL(song.info.uri)
.setThumbnail(song.info.artworkUrl)
.setDescription(
`**Duration:** ${
song.info.isStream ? 'LIVE' : client.utils.formatTime(song.info.length)
}\n**Requested by:** ${song.info.requester}\n**Link:** [Click here](${
song.info.uri
})`
`**Duration:** ${song.info.isStream ? 'LIVE' : client.utils.formatTime(song.info.length)}\n` +
`**Requested by:** ${song.info.requester}\n` +
`**Link:** [Click here](${song.info.uri})`
)
.setColor(client.color.main);
.setColor(this.client.color.main);

await ctx.author.send({ embeds: [dm] });
return await ctx.sendMessage({
embeds: [embed.setDescription(`**I sent you a DM.**`).setColor(client.color.green)],
embeds: [
embed.setDescription(`I sent you a DM.`).setColor(this.client.color.green),
],
});
} catch (e) {
return await ctx.sendMessage({
embeds: [
embed
.setDescription(`**I couldn't send you a DM.**`)
.setColor(client.color.red),
.setDescription(`I couldn't send you a DM.`)
.setColor(this.client.color.red),
],
});
}
Expand Down
1 change: 1 addition & 0 deletions src/commands/music/Join.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default class Join extends Command {
public async run(client: Lavamusic, ctx: Context): Promise<any> {
let player = client.queue.get(ctx.guild.id);
const embed = this.client.embed();

if (!player) {
const vc = ctx.member as any;
player = await client.queue.create(
Expand Down
4 changes: 2 additions & 2 deletions src/commands/music/Leave.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class Leave extends Command {
const player = client.queue.get(ctx.guild.id);
const embed = this.client.embed();
if (player) {
ctx.sendMessage({
await ctx.sendMessage({
embeds: [
embed
.setColor(this.client.color.main)
Expand All @@ -43,7 +43,7 @@ export default class Leave extends Command {
});
player.destroy();
} else {
ctx.sendMessage({
await ctx.sendMessage({
embeds: [
embed
.setColor(this.client.color.red)
Expand Down
30 changes: 13 additions & 17 deletions src/commands/music/Loop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default class Loop extends Command {
super(client, {
name: 'loop',
description: {
content: 'loop the current song or the queue',
content: 'Loop the current song or the queue',
examples: ['loop', 'loop queue', 'loop song'],
usage: 'loop',
},
Expand All @@ -29,32 +29,28 @@ export default class Loop extends Command {
});
}
public async run(client: Lavamusic, ctx: Context): Promise<any> {
const embed = client.embed().setColor(client.color.main);
const embed = this.client.embed().setColor(this.client.color.main);
const player = client.queue.get(ctx.guild.id);

let loopMessage = '';
switch (player.loop) {
case 'off':
player.loop = 'repeat';
return await ctx.sendMessage({
embeds: [
embed.setDescription(`**Looping the song**`).setColor(client.color.main),
],
});
loopMessage = '**Looping the song**';
break;
case 'repeat':
player.loop = 'queue';
return await ctx.sendMessage({
embeds: [
embed.setDescription(`**Looping the queue**`).setColor(client.color.main),
],
});
loopMessage = '**Looping the queue**';
break;
case 'queue':
player.loop = 'off';
return await ctx.sendMessage({
embeds: [
embed.setDescription(`**Looping is now off**`).setColor(client.color.main),
],
});
loopMessage = '**Looping is now off**';
break;
}

return await ctx.sendMessage({
embeds: [embed.setDescription(loopMessage)],
});
}
}

Expand Down
8 changes: 3 additions & 5 deletions src/commands/music/Nowplaying.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default class Nowplaying extends Command {
const position = player.player.position;
const duration = track.info.length;
const bar = client.utils.progressBar(position, duration, 20);
const embed1 = this.client
const embed = this.client
.embed()
.setColor(this.client.color.main)
.setAuthor({ name: 'Now Playing', iconURL: ctx.guild.iconURL({}) })
Expand All @@ -45,11 +45,9 @@ export default class Nowplaying extends Command {
)
.addFields({
name: '\u200b',
value: `\`${client.utils.formatTime(position)} / ${client.utils.formatTime(
duration
)}\``,
value: `\`${client.utils.formatTime(position)} / ${client.utils.formatTime(duration)}\``,
});
return await ctx.sendMessage({ embeds: [embed1] });
return await ctx.sendMessage({ embeds: [embed] });
}
}

Expand Down
1 change: 1 addition & 0 deletions src/commands/music/Pause.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export default class Pause extends Command {
public async run(client: Lavamusic, ctx: Context): Promise<any> {
const player = client.queue.get(ctx.guild.id);
const embed = this.client.embed();

if (!player.paused) {
player.pause();
return await ctx.sendMessage({
Expand Down
2 changes: 2 additions & 0 deletions src/commands/music/Play.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//TODO

import { LoadType } from 'shoukaku';

import { Command, Context, Lavamusic } from '../../structures/index.js';
Expand Down
2 changes: 2 additions & 0 deletions src/commands/music/PlayNext.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//TODO

import { LoadType } from 'shoukaku';

import { Command, Context, Lavamusic } from '../../structures/index.js';
Expand Down
30 changes: 15 additions & 15 deletions src/commands/music/Queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,43 +30,43 @@ export default class Queue extends Command {
}
public async run(client: Lavamusic, ctx: Context): Promise<any> {
const player = client.queue.get(ctx.guild.id);
if (player.queue.length === 0)
const embed = this.client.embed();

if (player.queue.length === 0) {
return await ctx.sendMessage({
embeds: [
this.client
.embed()
embed
.setColor(this.client.color.main)
.setDescription(
`Now playing: [${player.current.info.title}](${
player.current.info.uri
}) - Request By: ${player.current?.info.requester} - Duration: ${
player.current.info.isStream
? 'LIVE'
: this.client.utils.formatTime(player.current.info.length)
: client.utils.formatTime(player.current.info.length)
}`
),
],
});
}

const queue = player.queue.map(
(track, index) =>
`${index + 1}. [${track.info.title}](${track.info.uri}) - Request By: ${
track?.info.requester
} - Duration: ${
track.info.isStream ? 'LIVE' : this.client.utils.formatTime(track.info.length)
track.info.isStream ? 'LIVE' : client.utils.formatTime(track.info.length)
}`
);
let chunks = client.utils.chunk(queue, 10) as any;
if (chunks.length === 0) chunks = 1;
const pages = [];
for (let i = 0; i < chunks.length; i++) {
const embed = this.client
.embed()
const chunks = client.utils.chunk(queue, 10) || [[]];

const pages = chunks.map((chunk, index) =>
embed
.setColor(this.client.color.main)
.setAuthor({ name: 'Queue', iconURL: ctx.guild.iconURL({}) })
.setDescription(chunks[i].join('\n'))
.setFooter({ text: `Page ${i + 1} of ${chunks.length}` });
pages.push(embed);
}
.setDescription(chunk.join('\n'))
.setFooter({ text: `Page ${index + 1} of ${chunks.length}` })
);

return await client.utils.paginate(ctx, pages);
}
Expand Down
28 changes: 8 additions & 20 deletions src/commands/music/Remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export default class Remove extends Command {
public async run(client: Lavamusic, ctx: Context, args: string[]): Promise<any> {
const player = client.queue.get(ctx.guild.id);
const embed = this.client.embed();

if (!player.queue.length)
return await ctx.sendMessage({
embeds: [
Expand All @@ -46,36 +47,23 @@ export default class Remove extends Command {
.setDescription('There are no songs in the queue.'),
],
});
if (isNaN(Number(args[0])))
return await ctx.sendMessage({
embeds: [
embed
.setColor(this.client.color.red)
.setDescription('That is not a valid number.'),
],
});
if (Number(args[0]) > player.queue.length)
return await ctx.sendMessage({
embeds: [
embed
.setColor(this.client.color.red)
.setDescription('That is not a valid number.'),
],
});
if (Number(args[0]) < 1)

const songNumber = Number(args[0]);
if (isNaN(songNumber) || songNumber <= 0 || songNumber > player.queue.length)
return await ctx.sendMessage({
embeds: [
embed
.setColor(this.client.color.red)
.setDescription('That is not a valid number.'),
.setDescription('Please provide a valid song number.'),
],
});
player.remove(Number(args[0]) - 1);

player.remove(songNumber - 1);
return await ctx.sendMessage({
embeds: [
embed
.setColor(this.client.color.main)
.setDescription(`Removed song number ${Number(args[0])} from the queue`),
.setDescription(`Removed song number ${songNumber} from the queue`),
],
});
}
Expand Down
6 changes: 5 additions & 1 deletion src/commands/music/Resume.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,21 @@ export default class Resume extends Command {
options: [],
});
}

public async run(client: Lavamusic, ctx: Context): Promise<any> {
const player = client.queue.get(ctx.guild.id);
const embed = this.client.embed();
if (!player.paused)

if (!player.paused) {
return await ctx.sendMessage({
embeds: [
embed
.setColor(this.client.color.red)
.setDescription('The player is not paused.'),
],
});
}

player.pause();

return await ctx.sendMessage({
Expand Down
8 changes: 6 additions & 2 deletions src/commands/music/Search.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//TODO

import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from 'discord.js';
import { LoadType } from 'shoukaku';

Expand Down Expand Up @@ -40,7 +42,7 @@ export default class Search extends Command {
});
}
public async run(client: Lavamusic, ctx: Context, args: string[]): Promise<any> {
const embed = client.embed().setColor(client.color.main);
const embed = this.client.embed().setColor(this.client.color.main);
let player = client.queue.get(ctx.guild.id);
const query = args.join(' ');
if (!player) {
Expand All @@ -55,7 +57,9 @@ export default class Search extends Command {
const res = await this.client.queue.search(query);
if (!res)
return await ctx.sendMessage({
embeds: [embed.setDescription(`**No results found**`).setColor(client.color.red)],
embeds: [
embed.setDescription(`**No results found**`).setColor(this.client.color.red),
],
});
const row = new ActionRowBuilder().addComponents(
new ButtonBuilder().setCustomId('1').setLabel('1').setStyle(ButtonStyle.Primary),
Expand Down
Loading

0 comments on commit 9c0a6c7

Please sign in to comment.