Skip to content

Commit

Permalink
Minor optimisation
Browse files Browse the repository at this point in the history
  • Loading branch information
LakhindarPal committed Jun 22, 2024
1 parent 2c8244b commit 94c9d27
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 16 deletions.
Binary file modified bun.lockb
Binary file not shown.
7 changes: 4 additions & 3 deletions package-lock.json

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

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"main": "src/index.js",
"type": "module",
"scripts": {
"lint": "eslint src/**/*.js",
"lint:fix": "eslint src/**/*.js --fix",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"format": "prettier . --write",
"register": "node src/scripts/register.js",
"doc": "node src/scripts/cmd-doc.js",
Expand Down Expand Up @@ -54,6 +54,6 @@
"eslint": "^9.5.0",
"eslint-config-prettier": "^9.1.0",
"globals": "^15.6.0",
"prettier": "3.3.1"
"prettier": "3.3.2"
}
}
6 changes: 5 additions & 1 deletion src/commands/dev/eval.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* eslint-disable no-unused-vars */
import { codeBlock, ApplicationCommandOptionType, Colors } from "discord.js";
import * as DP from "discord-player";
import { inspect } from "node:util";
import { ErrorEmbed } from "../../modules/Embeds.js";

Expand All @@ -17,7 +19,7 @@ export const data = {
devOnly: true,
};

export async function execute(interaction) {
export async function execute(interaction, queue) {
await interaction.deferReply({ ephemeral: true });

const code = interaction.options.getString("code", true);
Expand All @@ -34,6 +36,8 @@ export async function execute(interaction) {
});
}

const client = interaction.client;

let result;
let error;
let executionTime;
Expand Down
18 changes: 12 additions & 6 deletions src/commands/music/play.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,20 @@ export async function execute(interaction) {
if (searchResult.hasPlaylist()) {
const playlist = searchResult.playlist;
embed
.setTitle(`Playlist enqueued - ${playlist.tracks.length} tracks.`)
.setDescription(`[${playlist.title}](${playlist.url})`);
.setAuthor({
name: `Playlist added - ${playlist.tracks.length} tracks.`,
iconURL: playlist.thumbnail,
})
.setTitle(playlist.title)
.setURL(playlist.url);
} else {
embed
.setTitle(
`Track enqueued - Position ${queue.node.getTrackPosition(track) + 1}`
)
.setDescription(track.toHyperlink());
.setAuthor({
name: `Track added - Position ${queue.node.getTrackPosition(track) + 1}`,
iconURL: track.thumbnail,
})
.setTitle(track.title)
.setURL(track.url);
}

return interaction.editReply({ embeds: [embed] }).catch(console.error);
Expand Down
10 changes: 7 additions & 3 deletions src/commands/music/songs.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ApplicationCommandOptionType } from "discord.js";
import { BaseEmbed, ErrorEmbed } from "../../modules/Embeds.js";
import { useHistory } from "discord-player";
import { BaseEmbed, ErrorEmbed } from "../../modules/Embeds.js";
import { titleCase } from "../../modules/utils.js";

export const data = {
name: "songs",
Expand Down Expand Up @@ -49,19 +50,22 @@ export function execute(interaction, queue) {
const tracks = songsdata.slice(start, end);

const embed = BaseEmbed()
.setAuthor({
iconURL: interaction.guild.iconURL(),
name: `${titleCase(type)} songs`,
})
.setDescription(
tracks
.map(
(track, i) =>
`${start + i + 1} - [${track.title}](${track.url}) ~ [${track.requestedBy.toString()}]`
`**${start + i + 1}**. [${track.title}](${track.url}) ~ [${track.requestedBy.toString()}]`
)
.join("\n")
)
.setFooter({
text: `Page ${page} of ${maxPage} | Showing songs ${start + 1} to ${
end > songsLength ? songsLength : end
} of ${songsLength}`,
iconURL: interaction.user.displayAvatarURL(),
});

return interaction.reply({ ephemeral: true, embeds: [embed] });
Expand Down

0 comments on commit 94c9d27

Please sign in to comment.