diff --git a/commands/Bot/help.js b/commands/Bot/help.js index 45ea8c1..f639763 100644 --- a/commands/Bot/help.js +++ b/commands/Bot/help.js @@ -1,63 +1,63 @@ -const { SlashCommandBuilder } = require("@discordjs/builders"); -const fs = require("fs"); -const path = require("path"); -const { EmbedBuilder } = require("discord.js"); +const { SlashCommandBuilder } = require("@discordjs/builders") +const fs = require("fs") +const path = require("path") +const { EmbedBuilder } = require("discord.js") module.exports = { data: new SlashCommandBuilder() .setName("help") .setDescription("Shows a list with every command available"), - async execute(interaction) { - const commandFolders = fs.readdirSync(path.join(__dirname, "..", "..", "commands")).filter(folder => folder !== "Inactive"); - const commands = []; + async execute (interaction) { + const commandFolders = fs.readdirSync(path.join(__dirname, "..", "..", "commands")).filter(folder => folder !== "Inactive") + const commands = [] for (const folder of commandFolders) { - const folderCommands = fs.readdirSync(path.join(__dirname, "..", "..", "commands", folder)).filter(file => file.endsWith(".js")); + const folderCommands = fs.readdirSync(path.join(__dirname, "..", "..", "commands", folder)).filter(file => file.endsWith(".js")) for (const file of folderCommands) { try { - const command = require(path.join(__dirname, "..", "..", "commands", folder, file)); + const command = require(path.join(__dirname, "..", "..", "commands", folder, file)) if (command.data) { - commands.push(command.data.toJSON()); + commands.push(command.data.toJSON()) } else { - console.log(`Command file ${file} in folder ${folder} doesn't have a data property.`); + console.log(`Command file ${file} in folder ${folder} doesn't have a data property.`) } } catch (error) { - console.log(`Error loading command file ${file} in folder ${folder}: ${error}`); + console.log(`Error loading command file ${file} in folder ${folder}: ${error}`) } } } - const sortedCommands = commands.sort((a, b) => a.name.localeCompare(b.name)); - const numCommands = sortedCommands.length; - let start = 0; - let end = Math.min(start + 10, numCommands); + const sortedCommands = commands.sort((a, b) => a.name.localeCompare(b.name)) + const numCommands = sortedCommands.length + let start = 0 + let end = Math.min(start + 10, numCommands) const embed = new EmbedBuilder() .setColor("#0000ff") - .setTitle(`Available (/) commands (Part ${Math.floor(start/10) + 1} of ${Math.ceil(numCommands/10)})`) + .setTitle(`Available (/) commands (Part ${Math.floor(start / 10) + 1} of ${Math.ceil(numCommands / 10)})`) .addFields(sortedCommands.slice(start, end).map(command => ({ name: `/${command.name}`, value: command.description, inline: false - }))); + }))) - await interaction.reply({ embeds: [embed] }); - start = end; + await interaction.reply({ embeds: [embed] }) + start = end while (start < numCommands) { - end = Math.min(start + 10, numCommands); + end = Math.min(start + 10, numCommands) const embed = new EmbedBuilder() .setColor("#0000ff") - .setTitle(`Available (/) commands (Part ${Math.floor(start/10) + 1} of ${Math.ceil(numCommands/10)})`) + .setTitle(`Available (/) commands (Part ${Math.floor(start / 10) + 1} of ${Math.ceil(numCommands / 10)})`) .addFields(sortedCommands.slice(start, end).map(command => ({ name: `/${command.name}`, value: command.description, inline: false - }))); + }))) - await interaction.followUp({ embeds: [embed] }); - start = end; + await interaction.followUp({ embeds: [embed] }) + start = end } } -}; +} diff --git a/commands/Music/queue.js b/commands/Music/queue.js index 2307e09..7715f6b 100644 --- a/commands/Music/queue.js +++ b/commands/Music/queue.js @@ -7,41 +7,41 @@ module.exports = { .setName("queue") .setDescription("Displays the current songs in the music queue"), - async execute(interaction) { - const queue = await distube.getQueue(interaction) - - if (!queue) { - const queueError = new EmbedBuilder() - .setDescription("There is currently no song in the queue!") - .setColor("#FF0000") - - return interaction.reply({ embeds: [queueError], ephemeral: true }) - } - - const queueItems = queue.songs.map((song, i) => { - return `${i === 0 ? "Playing:" : `${i}.`} ${song.name} - \`${song.formattedDuration}\`` - }) - - const chunkSize = 10 // Number of items to print in each message - const chunkedQueue = [] - - for (let i = 0; i < queueItems.length; i += chunkSize) { - chunkedQueue.push(queueItems.slice(i, i + chunkSize)) - } - - for (let i = 0; i < chunkedQueue.length; i++) { - const currentPart = i + 1 - const totalParts = chunkedQueue.length - const embed = new EmbedBuilder() - .setTitle(`**Current queue (Part ${currentPart}/${totalParts})**`) - .setDescription(`\n\n${chunkedQueue[i].join("\n")}`) - .setColor("#FFFF00") - - if (i === 0) { - await interaction.reply({ embeds: [embed] }) - } else { - await interaction.followUp({ embeds: [embed] }) - } + async execute (interaction) { + const queue = await distube.getQueue(interaction) + + if (!queue) { + const queueError = new EmbedBuilder() + .setDescription("There is currently no song in the queue!") + .setColor("#FF0000") + + return interaction.reply({ embeds: [queueError], ephemeral: true }) + } + + const queueItems = queue.songs.map((song, i) => { + return `${i === 0 ? "Playing:" : `${i}.`} ${song.name} - \`${song.formattedDuration}\`` + }) + + const chunkSize = 10 // Number of items to print in each message + const chunkedQueue = [] + + for (let i = 0; i < queueItems.length; i += chunkSize) { + chunkedQueue.push(queueItems.slice(i, i + chunkSize)) + } + + for (let i = 0; i < chunkedQueue.length; i++) { + const currentPart = i + 1 + const totalParts = chunkedQueue.length + const embed = new EmbedBuilder() + .setTitle(`**Current queue (Part ${currentPart}/${totalParts})**`) + .setDescription(`\n\n${chunkedQueue[i].join("\n")}`) + .setColor("#FFFF00") + + if (i === 0) { + await interaction.reply({ embeds: [embed] }) + } else { + await interaction.followUp({ embeds: [embed] }) } - } + } + } } diff --git a/package-lock.json b/package-lock.json index a85d828..793be73 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "dicobo", - "version": "1.2.4", + "version": "1.2.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "dicobo", - "version": "1.2.4", + "version": "1.2.5", "license": "MIT", "dependencies": { "@ballaual/discord-temp-channels": "^4.0.1", diff --git a/package.json b/package.json index 215c079..2270c3a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dicobo", - "version": "1.2.4", + "version": "1.2.5", "description": "a discordbot written in discord.js v14 using (/) commands", "main": "app.js", "scripts": { diff --git a/version.json b/version.json index 97a56e0..21728cb 100644 --- a/version.json +++ b/version.json @@ -1,4 +1,4 @@ { - "version": "1.2.4", + "version": "1.2.5", "note": "DO NOT EDIT this file, unless you know what you are doing here!" } \ No newline at end of file