mirror of
https://github.com/Alee14/DLAP.git
synced 2025-01-22 10:52:03 -05:00
Updated packages; Lists now uses queue; Credits
This commit is contained in:
parent
368d580f97
commit
d62339796f
4 changed files with 46 additions and 31 deletions
|
@ -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' }
|
||||
|
|
|
@ -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,18 +33,21 @@ 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 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 await interaction.reply({ content: t('invalidPage', { numPages }), ephemeral: true });
|
||||
return interaction.reply({ content: t('invalidPage', { numPages }), ephemeral: true });
|
||||
}
|
||||
// Split the track list into pages
|
||||
const pages = [];
|
||||
|
@ -58,8 +62,19 @@ export default {
|
|||
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] });
|
||||
interaction.reply({ embeds: [listEmbed] });
|
||||
};
|
||||
|
||||
if (queue) {
|
||||
listTracks(queuedFiles);
|
||||
} else {
|
||||
readdir(musicFolder, (err, files) => {
|
||||
if (err) {
|
||||
console.error(err);
|
||||
} else {
|
||||
listTracks(files);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
BIN
bun.lockb
Executable file
BIN
bun.lockb
Executable file
Binary file not shown.
10
package.json
10
package.json
|
@ -10,12 +10,12 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@discordjs/opus": "^0.9.0",
|
||||
"@discordjs/voice": "^0.16.1",
|
||||
"discord.js": "^14.14.1",
|
||||
"@discordjs/voice": "^0.17.0",
|
||||
"discord.js": "^14.16.2",
|
||||
"ffmpeg-static": "^5.2.0",
|
||||
"i18next": "^23.8.2",
|
||||
"i18next-fs-backend": "^2.3.1",
|
||||
"music-metadata": "^7.14.0",
|
||||
"i18next": "^23.15.1",
|
||||
"i18next-fs-backend": "^2.3.2",
|
||||
"music-metadata": "^10.5.0",
|
||||
"sodium": "^3.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
Loading…
Reference in a new issue