aboutsummaryrefslogtreecommitdiff
path: root/Commands
diff options
context:
space:
mode:
Diffstat (limited to 'Commands')
-rw-r--r--Commands/about.js2
-rw-r--r--Commands/list.js65
2 files changed, 41 insertions, 26 deletions
diff --git a/Commands/about.js b/Commands/about.js
index 8b63ca2..4b8a9ea 100644
--- a/Commands/about.js
+++ b/Commands/about.js
@@ -36,7 +36,7 @@ export default {
{ name: t('aboutInfo'), value: t('aboutInfoValue') },
{ name: t('aboutBotVersion'), value: `DLAP ${npmPackage.version}` },
{ name: t('aboutCreator'), value: 'Andrew Lee (alee)' }, // Do not remove this since I created this :)
- { name: t('aboutContributors'), value: 'Victor Moraes (Vicktor#7232) (Improving README)\nParlance Translation Team' },
+ { name: t('aboutContributors'), value: 'Victor Moraes (Vicktor#7232) (Improving README)\nAizuddin Akmal (AizuddinAkmal) (Improved Dockerfile)\nParlance Translation Team' },
// { name: t('aboutForked'), value: '[your name] (username)' },
{ name: t('aboutFrameworks'), value: `Discord.JS ${version}\nmusic-metadata\ni18next` },
{ name: t('aboutLicense'), value: 'GNU General Public License v3.0' }
diff --git a/Commands/list.js b/Commands/list.js
index e2498d8..6a308e6 100644
--- a/Commands/list.js
+++ b/Commands/list.js
@@ -22,6 +22,7 @@
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
import { readdir } from 'node:fs';
import i18next from '../Utilities/i18n.js';
+import { files as queuedFiles } from '../AudioBackend/AudioControl.js';
const musicFolder = './music';
const t = i18next.t;
@@ -32,34 +33,48 @@ export default {
.addIntegerOption(option =>
option.setName('page')
.setDescription('Input a number to change the page of the list')
+ )
+ .addBooleanOption(option =>
+ option.setName('queue')
+ .setDescription('Lists the audio tracks from the queue')
),
async execute(interaction, bot) {
const page = interaction.options.getInteger('page') || 1; // If no page is specified, default to page 1
- readdir(musicFolder, async(err, files) => {
- if (err) {
- console.error(err);
- } else {
- const trackList = files.map((file, i) => `${i}: ${file}`); // Create an array of track names
- const pageSize = 20; // Number of tracks per page
- const numPages = Math.ceil(trackList.length / pageSize); // Total number of pages
- if (page < 1 || page > numPages) { // Check if the page number is valid
- return await interaction.reply({ content: t('invalidPage', { numPages }), ephemeral: true });
- }
- // Split the track list into pages
- const pages = [];
- for (let i = 0; i < numPages; i++) {
- const start = i * pageSize;
- const end = start + pageSize;
- pages.push(trackList.slice(start, end));
- }
- // Send the specified page with the page number and total number of pages
- const listEmbed = new EmbedBuilder();
- listEmbed.setAuthor({ name: t('listTitle', { bot: bot.user.username }), iconURL: bot.user.avatarURL() });
- listEmbed.addFields({ name: t('listTracks', { trackList: trackList.length }), value: `\`\`\`\n${pages[page - 1].join('\n')}\n\`\`\`` });
- listEmbed.setFooter({ text: t('listPage') + ` ${page}/${numPages}` });
- listEmbed.setColor('#0066ff');
- await interaction.reply({ embeds: [listEmbed] });
+ const queue = interaction.options.getBoolean('queue') !== false; // Check if queue option is true
+
+ const listTracks = (tracks) => {
+ const trackList = tracks.map((file, i) => `${i}: ${file}`); // Create an array of track names
+ const pageSize = 20; // Number of tracks per page
+ const numPages = Math.ceil(trackList.length / pageSize); // Total number of pages
+ if (page < 1 || page > numPages) { // Check if the page number is valid
+ return interaction.reply({ content: t('invalidPage', { numPages }), ephemeral: true });
}
- });
+ // Split the track list into pages
+ const pages = [];
+ for (let i = 0; i < numPages; i++) {
+ const start = i * pageSize;
+ const end = start + pageSize;
+ pages.push(trackList.slice(start, end));
+ }
+ // Send the specified page with the page number and total number of pages
+ const listEmbed = new EmbedBuilder();
+ listEmbed.setAuthor({ name: t('listTitle', { bot: bot.user.username }), iconURL: bot.user.avatarURL() });
+ listEmbed.addFields({ name: t('listTracks', { trackList: trackList.length }), value: `\`\`\`\n${pages[page - 1].join('\n')}\n\`\`\`` });
+ listEmbed.setFooter({ text: t('listPage') + ` ${page}/${numPages}` });
+ listEmbed.setColor('#0066ff');
+ interaction.reply({ embeds: [listEmbed] });
+ };
+
+ if (queue) {
+ listTracks(queuedFiles);
+ } else {
+ readdir(musicFolder, (err, files) => {
+ if (err) {
+ console.error(err);
+ } else {
+ listTracks(files);
+ }
+ });
+ }
}
};