aboutsummaryrefslogtreecommitdiff
path: root/commands/status.js
diff options
context:
space:
mode:
Diffstat (limited to 'commands/status.js')
-rw-r--r--commands/status.js29
1 files changed, 25 insertions, 4 deletions
diff --git a/commands/status.js b/commands/status.js
index 654b496..b564a88 100644
--- a/commands/status.js
+++ b/commands/status.js
@@ -20,7 +20,8 @@
***************************************************************************/
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js';
-import { audio, currentTrack, files, playerState } from '../AudioBackend.js';
+import { parseFile } from 'music-metadata';
+import { audio, currentTrack, files, playerState, audioTitle, metadataEmpty } from '../AudioBackend.js';
export default {
data: new SlashCommandBuilder()
@@ -31,19 +32,39 @@ export default {
audioID++;
let audioName = files[audioID];
+
if (audioName === undefined) {
audioName = 'Playlist Finished';
} else {
- audioName = audioName.split('.').slice(0, -1).join('.');
+ if (metadataEmpty === false) {
+ try {
+ const { common } = await parseFile('music/' + audioName);
+ audioName = common.title;
+ } catch (error) {
+ console.error(error.message);
+ }
+ } else {
+ audioName = audioName.split('.').slice(0, -1).join('.');
+ }
}
const controlEmbed = new EmbedBuilder()
.setAuthor({ name: `${bot.user.username} Status`, iconURL: bot.user.avatarURL() })
.addFields({ name: 'State', value: playerState })
.addFields({ name: 'Tracks', value: `${audioID}/${files.length}` })
- .addFields({ name: 'Currently Playing', value: audio })
- .addFields({ name: 'Up Next', value: audioName })
.setColor('#0066ff');
+
+ if (metadataEmpty === true) {
+ controlEmbed.addFields(
+ { name: 'Currently Playing', value: audio },
+ { name: 'Up Next', value: audioName }
+ );
+ } else {
+ controlEmbed.addFields(
+ { name: 'Currently Playing', value: audioTitle },
+ { name: 'Up Next', value: audioName }
+ );
+ }
interaction.reply({ embeds: [controlEmbed] });
}
};