diff options
Diffstat (limited to 'Commands/status.js')
| -rw-r--r-- | Commands/status.js | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/Commands/status.js b/Commands/status.js index aeb909d..ee02126 100644 --- a/Commands/status.js +++ b/Commands/status.js @@ -22,9 +22,11 @@ import { EmbedBuilder, SlashCommandBuilder } from 'discord.js'; import { parseFile } from 'music-metadata'; import { audio, metadataEmpty, duration, audioTitle, currentTrack } from '../AudioBackend/PlayAudio.js'; -import { files, playerState } from '../AudioBackend/AudioControl.js'; +import { files, playerState, playerStatus } from '../AudioBackend/AudioControl.js'; import { votes } from '../Utilities/Voting.js'; +import i18next from '../Utilities/i18n.js'; +const t = i18next.t; export default { data: new SlashCommandBuilder() .setName('status') @@ -38,19 +40,19 @@ export default { // Get the members of the voice channel who have not voted yet const voiceChannel = interaction.member.voice.channel; - const members = voiceChannel.members.filter(m => !votes.has(m.id)); + const members = voiceChannel.members.filter(m => !votes.has(m.id) && !m.user.bot); // Calculate the number of votes required to skip the audio track - const votesRequired = Math.ceil((members.size - votes.size) / 2); + const votesRequired = Math.ceil(members.size / 2); if (audioID >= files.length) { - audioName = 'Playlist Finished'; + audioName = t('playlistDone'); } else { audioName = files[audioID]; if (!metadataEmpty) { try { const { common } = await parseFile('music/' + audioName); - audioName = common.title; + audioName = common.title ? common.title : audioName.split('.').slice(0, -1).join('.'); } catch (error) { console.error(error.message); } @@ -60,25 +62,27 @@ export default { } const controlEmbed = new EmbedBuilder() - .setAuthor({ name: `${bot.user.username} Status`, iconURL: bot.user.avatarURL() }) + .setAuthor({ name: t('statusTitle', { bot: bot.user.username }), iconURL: bot.user.avatarURL() }) .addFields( - { name: 'State', value: `${playerState}` }, - { name: 'Tracks', value: `${audioID}/${files.length}` }, - { name: 'Duration', value: `${duration}` }, - { name: 'Votes Needed', value: `${votesRequired}` } + { name: t('statusState'), value: `${playerState}` }, + { name: t('statusTracks'), value: `${audioID}/${files.length}` }, + { name: t('musicDuration'), value: `${duration}` }, + { name: t('statusVotesNeeded'), value: `${votesRequired}` } ) .setColor('#0066ff'); - if (metadataEmpty) { - 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}` } - ); + if (playerStatus === 0 || playerStatus === 1) { + if (metadataEmpty) { + controlEmbed.addFields( + { name: t('currentlyPlaying'), value: `${audio}` }, + { name: t('upNext'), value: `${audioName}` } + ); + } else { + controlEmbed.addFields( + { name: t('currentlyPlaying'), value: `${audioTitle}` }, + { name: t('upNext'), value: `${audioName}` } + ); + } } interaction.reply({ embeds: [controlEmbed] }); } |
