diff options
| author | Andrew Lee <alee14498@protonmail.com> | 2022-11-28 22:17:18 -0500 |
|---|---|---|
| committer | Andrew Lee <alee14498@protonmail.com> | 2022-11-28 22:17:18 -0500 |
| commit | c4300f9955c2757369fd800e1736c19a4b69b276 (patch) | |
| tree | 95ea698c5e9afa048d839333fd5cbd4d460d1029 /commands | |
| parent | 246dba3089e970f009c6579d405d8553ca441b7a (diff) | |
| download | DLAP-c4300f9955c2757369fd800e1736c19a4b69b276.tar.gz DLAP-c4300f9955c2757369fd800e1736c19a4b69b276.tar.bz2 DLAP-c4300f9955c2757369fd800e1736c19a4b69b276.zip | |
Added metadata support
Diffstat (limited to 'commands')
| -rw-r--r-- | commands/status.js | 29 |
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] }); } }; |
