Skip to content

Commit

Permalink
v4.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasB25 committed Jul 18, 2024
1 parent 7aa5dec commit a2231b7
Show file tree
Hide file tree
Showing 31 changed files with 179 additions and 163 deletions.
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lavamusic",
"version": "4.4.3",
"version": "4.6.3",
"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 Expand Up @@ -36,11 +36,8 @@
"homepage": "https://github.com/appujet/lavamusic#readme",
"devDependencies": {
"@biomejs/biome": "^1.8.3",

"@types/node": "^20.14.11",

"@types/i18n": "^0.13.12",
"@types/node": "^20.14.10",
"@types/signale": "^1.4.7",
"prisma": "^5.17.0",
"typescript": "^5.5.3"
Expand Down
8 changes: 5 additions & 3 deletions src/commands/config/247.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ export default class _247 extends Command {
const member = ctx.member as GuildMember;
if (!member.voice.channel) {
return await ctx.sendMessage({
embeds: [embed.setDescription("You need to be in a voice channel to use this command.").setColor(client.color.red)],
embeds: [
embed.setDescription("You need to be in a voice channel to use this command.").setColor(this.client.color.red),
],
});
}
if (data) {
await client.db.delete_247(ctx.guild.id);
return await ctx.sendMessage({
embeds: [embed.setDescription("**24/7 mode has been disabled**").setColor(client.color.red)],
embeds: [embed.setDescription("**24/7 mode has been disabled**").setColor(this.client.color.red)],
});
}
await client.db.set_247(ctx.guild.id, ctx.channel.id, member.voice.channel.id);
Expand All @@ -68,7 +70,7 @@ export default class _247 extends Command {
} catch (error) {
console.error("Error in 247 command:", error);
return await ctx.sendMessage({
embeds: [embed.setDescription("An error occurred while trying to execute this command.").setColor(client.color.red)],
embeds: [embed.setDescription("An error occurred while trying to execute this command.").setColor(this.client.color.red)],
});
}
}
Expand Down
1 change: 0 additions & 1 deletion src/commands/info/About.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ export default class About extends Command {
},
);
await ctx.sendMessage({
content: "",
embeds: [embed],
components: [row],
});
Expand Down
2 changes: 1 addition & 1 deletion src/commands/info/Botinfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default class Botinfo extends Command {
const osUptime = client.utils.formatTime(os.uptime());
const osHostname = os.hostname();
const cpuInfo = `${os.arch()} (${os.cpus().length} cores)`;
const cpuUsed = (await usagePercent({ coreIndex: 0, sampleMs: 2000 })).percent;
const cpuUsed = (await usagePercent({ coreIndex: 0, sampleMs: 2000 })).percent.toFixed(2);
const memTotal = showTotalMemory(true);
const memUsed = (process.memoryUsage().rss / 1024 ** 2).toFixed(2);
const nodeVersion = process.version;
Expand Down
19 changes: 8 additions & 11 deletions src/commands/info/Help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ export default class Help extends Command {
const guild = await client.db.get(ctx.guild.id);
const commands = this.client.commands.filter((cmd) => cmd.category !== "dev");
const categories = [...new Set(commands.map((cmd) => cmd.category))];

if (args[0]) {
const command = this.client.commands.get(args[0].toLowerCase());
if (!command) {
return await ctx.sendMessage({
embeds: [client.embed().setColor(client.color.red).setDescription(ctx.locale("cmd.help.not_found", { cmdName: args[0] }))],
embeds: [embed.setColor(this.client.color.red).setDescription(ctx.locale("cmd.help.not_found", { cmdName: args[0] }))],
});
}
const helpEmbed = embed
Expand Down Expand Up @@ -73,6 +74,7 @@ export default class Help extends Command {
);
return await ctx.sendMessage({ embeds: [helpEmbed] });
}

const fields = categories.map((category) => ({
name: category,
value: commands
Expand All @@ -81,19 +83,14 @@ export default class Help extends Command {
.join(", "),
inline: false,
}));

const helpEmbed = embed
.setColor(client.color.main)
.setTitle(ctx.locale("cmd.help.title"))
.setDescription(
ctx.locale("cmd.help.content", {
bot: client.user.username,
prefix: guild.prefix,
}),
)
.setFooter({
text: ctx.locale("cmd.help.footer", { prefix: guild.prefix }),
});
helpEmbed.addFields(...fields);
.setDescription(ctx.locale("cmd.help.content", { bot: client.user.username, prefix: guild.prefix }))
.setFooter({ text: ctx.locale("cmd.help.footer", { prefix: guild.prefix }) })
.addFields(...fields);

return await ctx.sendMessage({ embeds: [helpEmbed] });
}
}
Expand Down
7 changes: 1 addition & 6 deletions src/commands/info/Invite.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from "discord.js";
import { Command, type Context, type Lavamusic } from "../../structures/index.js";


export default class Invite extends Command {
constructor(client: Lavamusic) {
super(client, {
Expand Down Expand Up @@ -43,11 +42,7 @@ export default class Invite extends Command {
new ButtonBuilder().setLabel(ctx.locale("buttons.support")).setStyle(ButtonStyle.Link).setURL("https://discord.gg/STXurwnZD5"),
);
return await ctx.sendMessage({
embeds: [
embed
.setColor(this.client.color.main)
.setDescription(ctx.locale("cmd.invite.content"))
],
embeds: [embed.setColor(this.client.color.main).setDescription(ctx.locale("cmd.invite.content"))],
components: [row],
});
}
Expand Down
5 changes: 3 additions & 2 deletions src/commands/info/LavaLink.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Command, type Context, type Lavamusic } from "../../structures/index.js";


export default class LavaLink extends Command {
constructor(client: Lavamusic) {
super(client, {
Expand Down Expand Up @@ -35,8 +34,9 @@ export default class LavaLink extends Command {
.embed()
.setTitle(ctx.locale("cmd.lavalink.title"))
.setColor(this.client.color.main)
.setThumbnail(this.client.user.avatarURL({}))
.setThumbnail(this.client.user.avatarURL())
.setTimestamp();

client.shoukaku.nodes.forEach((node) => {
const statusEmoji = node.stats ? "🟢" : "🔴";
const stats = node.stats || {
Expand Down Expand Up @@ -64,6 +64,7 @@ export default class LavaLink extends Command {
value: formattedStats,
});
});

return await ctx.sendMessage({ embeds: [embed] });
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/commands/music/ClearQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ 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 === 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({
embeds: [embed.setColor(this.client.color.main).setDescription("Cleared the queue.")],
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 @@ -5,7 +5,7 @@ export default class Grab extends Command {
super(client, {
name: "grab",
description: {
content: "Grabs the current playing song on your DM",
content: "Grabs the current playing song in your DM",
examples: ["grab"],
usage: "grab",
},
Expand Down Expand Up @@ -33,19 +33,21 @@ export default class Grab extends Command {
const embed = this.client.embed().setColor(this.client.color.main);
const player = client.queue.get(ctx.guild.id);
const song = player.current;

const dmEmbed = 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})`,
)
.setColor(this.client.color.main);

try {
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})`,
)
.setColor(this.client.color.main);
await ctx.author.send({ embeds: [dm] });
await ctx.author.send({ embeds: [dmEmbed] });
return await ctx.sendMessage({
embeds: [embed.setDescription("Please check your DM.").setColor(this.client.color.green)],
});
Expand Down
11 changes: 7 additions & 4 deletions src/commands/music/Join.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,30 @@ 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();
const voiceChannel = (ctx.member as any).voice.channel;

if (player) {
return await ctx.sendMessage({
embeds: [
embed
.setColor(this.client.color.main)
.setDescription(`I'm already connected to <#${player.node.manager.connections.get(ctx.guild.id).channelId}>`),
.setDescription(`I'm already connected to <#${player.node.manager.connections.get(ctx.guild.id)?.channelId}>`),
],
});
}
const vc = ctx.member as any;

player = await client.queue.create(
ctx.guild,
vc.voice.channel,
voiceChannel,
ctx.channel,
client.shoukaku.options.nodeResolver(client.shoukaku.nodes),
);

return await ctx.sendMessage({
embeds: [
embed
.setColor(this.client.color.main)
.setDescription(`Joined <#${player.node.manager.connections.get(ctx.guild.id).channelId}>`),
.setDescription(`Joined <#${player.node.manager.connections.get(ctx.guild.id)?.channelId}>`),
],
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/commands/music/Leave.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default class Leave extends Command {
embeds: [
embed
.setColor(this.client.color.main)
.setDescription(`Left <#${player.node.manager.connections.get(ctx.guild.id).channelId}>`),
.setDescription(`Left <#${player.node.manager.connections.get(ctx.guild.id)?.channelId}>`),
],
});
player.destroy();
Expand Down
2 changes: 2 additions & 0 deletions src/commands/music/Loop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export default class Loop extends Command {
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";
Expand All @@ -47,6 +48,7 @@ export default class Loop extends Command {
loopMessage = "**Looping is now off.**";
break;
}

return await ctx.sendMessage({
embeds: [embed.setDescription(loopMessage)],
});
Expand Down
4 changes: 3 additions & 1 deletion src/commands/music/Nowplaying.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,18 @@ 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 embed = this.client
.embed()
.setColor(this.client.color.main)
.setAuthor({ name: "Now Playing", iconURL: ctx.guild.iconURL({}) })
.setThumbnail(track.info.artworkUrl)
.setDescription(`[${track.info.title}](${track.info.uri}) - Request By: ${track.info.requester}\n\n\`${bar}\``)
.setDescription(`[${track.info.title}](${track.info.uri}) - Requested by: ${track.info.requester}\n\n\`${bar}\``)
.addFields({
name: "\u200b",
value: `\`${client.utils.formatTime(position)} / ${client.utils.formatTime(duration)}\``,
});

return await ctx.sendMessage({ embeds: [embed] });
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/commands/music/Pause.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ 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) {
return await ctx.sendMessage({
embeds: [embed.setColor(this.client.color.red).setDescription("The song is already paused.")],
});
}

player.pause();
return await ctx.sendMessage({
embeds: [embed.setColor(this.client.color.main).setDescription("Successfully paused the song.")],
Expand Down
Loading

0 comments on commit a2231b7

Please sign in to comment.