63 lines
2.1 KiB
TypeScript
63 lines
2.1 KiB
TypeScript
import { EmbedBuilder, SlashCommandBuilder } from 'discord.js'
|
|
import { splitBar } from 'string-progressbar'
|
|
import { bot } from '../../index'
|
|
import { i18n } from '../../utils/i18n'
|
|
import { SlashCommand } from '../../sturctures/command'
|
|
|
|
export const command: SlashCommand = {
|
|
slashData: new SlashCommandBuilder()
|
|
.setName('nowplaying')
|
|
.setDescription(i18n.__('nowplaying.description')),
|
|
run: (itd) => {
|
|
const { interaction }: any = itd
|
|
const queue = bot.queues.get(interaction.guild!.id)
|
|
|
|
console.log(i18n.__('nowplaying.description'))
|
|
if (!queue || !queue.songs.length)
|
|
return interaction
|
|
.reply({
|
|
content: i18n.__('nowplaying.errorNotQueue'),
|
|
ephemeral: true,
|
|
})
|
|
.catch(console.error)
|
|
|
|
const song = queue.songs[0]
|
|
const seek = queue.resource.playbackDuration / 1000
|
|
const left = song.duration - seek
|
|
|
|
const nowPlaying = new EmbedBuilder()
|
|
.setTitle(i18n.__('nowplaying.embedTitle'))
|
|
.setDescription(`${song.title}\n${song.url}`)
|
|
.setColor('#F8AA2A')
|
|
|
|
if (song.duration > 0) {
|
|
nowPlaying.addFields({
|
|
name: '\u200b',
|
|
value:
|
|
new Date(seek * 1000).toISOString().substr(11, 8) +
|
|
'[' +
|
|
splitBar(
|
|
song.duration == 0 ? seek : song.duration,
|
|
seek,
|
|
20
|
|
)[0] +
|
|
']' +
|
|
(song.duration == 0
|
|
? ' ◉ LIVE'
|
|
: new Date(song.duration * 1000)
|
|
.toISOString()
|
|
.substr(11, 8)),
|
|
inline: false,
|
|
})
|
|
|
|
nowPlaying.setFooter({
|
|
text: i18n.__mf('nowplaying.timeRemaining', {
|
|
time: new Date(left * 1000).toISOString().substr(11, 8),
|
|
}),
|
|
})
|
|
}
|
|
|
|
return interaction.reply({ embeds: [nowPlaying] })
|
|
},
|
|
}
|