player.timeRemains()

Is there is a way to find out how many milliseconds are left for the current song?
29 Replies
1Lucas1.apk
1Lucas1.apk•2y ago
Hello All good A simple solution is to do a mathematical calculation
let remainingTime = player.current.duration - player.current.position
let remainingTime = player.current.duration - player.current.position
foreign-sapphire
foreign-sapphireOP•2y ago
thx, i was wondering what the player.current field was. thought it was the current track
1Lucas1.apk
1Lucas1.apk•2y ago
🤭 Have a great day
foreign-sapphire
foreign-sapphireOP•2y ago
u2 @1Lucas1.apk sorry for ping, but how can i get the current track if one is playing?
1Lucas1.apk
1Lucas1.apk•2y ago
It's player.current
foreign-sapphire
foreign-sapphireOP•2y ago
current is always null btw
1Lucas1.apk
1Lucas1.apk•2y ago
?eval client.moon.players.get(message.guild.id).current
Blobit - Moonlink.js
{
encoded: 'QAAAqwMAElJpaGFubmEgLSBEaWFtb25kcwAHUmloYW5uYQAAAAAABFF4AAtsV0EycGpNanBCcwABACtodHRwczovL3d3dy55b3V0dWJlLmNvbS93YXRjaD92PWxXQTJwak1qcEJzAQA0aHR0cHM6Ly9pLnl0aW1nLmNvbS92aS9sV0EycGpNanBCcy9tYXhyZXNkZWZhdWx0LmpwZwAAB3lvdXR1YmUAAAAAAAAAAA==',
identifier: 'lWA2pjMjpBs',
title: 'Rihanna - Diamonds',
author: 'Rihanna',
url: 'https://www.youtube.com/watch?v=lWA2pjMjpBs',
duration: 283000,
position: [Getter],
isSeekable: true,
isStream: false,
sourceName: 'youtube',
requester: null,
artworkUrl: 'https://i.ytimg.com/vi/lWA2pjMjpBs/maxresdefault.jpg',
isrc: null,
thumbnail: undefined,
time: 1697810337823,
ping: 13
}
{
encoded: 'QAAAqwMAElJpaGFubmEgLSBEaWFtb25kcwAHUmloYW5uYQAAAAAABFF4AAtsV0EycGpNanBCcwABACtodHRwczovL3d3dy55b3V0dWJlLmNvbS93YXRjaD92PWxXQTJwak1qcEJzAQA0aHR0cHM6Ly9pLnl0aW1nLmNvbS92aS9sV0EycGpNanBCcy9tYXhyZXNkZWZhdWx0LmpwZwAAB3lvdXR1YmUAAAAAAAAAAA==',
identifier: 'lWA2pjMjpBs',
title: 'Rihanna - Diamonds',
author: 'Rihanna',
url: 'https://www.youtube.com/watch?v=lWA2pjMjpBs',
duration: 283000,
position: [Getter],
isSeekable: true,
isStream: false,
sourceName: 'youtube',
requester: null,
artworkUrl: 'https://i.ytimg.com/vi/lWA2pjMjpBs/maxresdefault.jpg',
isrc: null,
thumbnail: undefined,
time: 1697810337823,
ping: 13
}
foreign-sapphire
foreign-sapphireOP•2y ago
thx that's weird but i can check again
1Lucas1.apk
1Lucas1.apk•2y ago
Is there any problem getting it on the map?
foreign-sapphire
foreign-sapphireOP•2y ago
no i don't belive so
Blobit - Moonlink.js
Map(6) {
'sessionId' => '3bthcwngi98aip0w',
'players' => {
'990369410344701964': {
guildId: '990369410344701964',
textChannel: '1151684866971275325',
voiceChannel: '1089198118022680626',
volume: 80,
playing: true,
connected: true,
paused: false,
shuffled: false,
loop: null,
autoPlay: true,
node: 'lavalink-replit-2.1lucas1apk.repl.co'
}
},
'voiceStates' => {
'990369410344701964': {
member: [Object],
user_id: '960185850346471505',
suppress: false,
session_id: 'e6bbd949edf477b2c228a6a2dc238125',
self_video: false,
self_mute: false,
self_deaf: false,
request_to_speak_timestamp: null,
mute: false,
guild_id: '990369410344701964',
deaf: false,
channel_id: '1089198118022680626'
}
},
'voiceServer' => { '990369410344701964': { event: [Object] } },
'current' => {
'990369410344701964': {
encoded: 'QAAAqwMAElJpaGFubmEgLSBEaWFtb25kcwAHUmloYW5uYQAAAAAABFF4AAtsV0EycGpNanBCcwABACtodHRwczovL3d3dy55b3V0dWJlLmNvbS93YXRjaD92PWxXQTJwak1qcEJzAQA0aHR0cHM6Ly9pLnl0aW1nLmNvbS92aS9sV0EycGpNanBCcy9tYXhyZXNkZWZhdWx0LmpwZwAAB3lvdXR1YmUAAAAAAAAAAA==',
identifier: 'lWA2pjMjpBs',
title: 'Rihanna - Diamonds',
author: 'Rihanna',
url: 'https://www.youtube.com/watch?v=lWA2pjMjpBs',
duration: 283000,
position: [Getter],
isSeekable: true,
isStream: false,
sourceName: 'youtube',
requester: null,
artworkUrl: 'https://i.ytimg.com/vi/lWA2pjMjpBs/maxresdefault.jpg',
isrc: null,
thumbnail: undefined,
time: 1697810407823,
ping: 14
}
},
'previous' => {
'990369410344701964': {
encoded: 'QAAA2gMAOUNocmlzdGluYSBQZXJyaSAtIEEgVGhvdXNhbmQgWWVhcnMgW09mZmljaWFsIE11c2ljIFZpZGVvXQAPQ2hyaXN0aW5hIFBlcnJpAAAAAAAEZQAAC3J0T3ZCT1R5WDAwAAEAK2h0dHBzOi8vd3d3LnlvdXR1YmUuY29tL3dhdGNoP3Y9cnRPdkJPVHlYMDABA
Map(6) {
'sessionId' => '3bthcwngi98aip0w',
'players' => {
'990369410344701964': {
guildId: '990369410344701964',
textChannel: '1151684866971275325',
voiceChannel: '1089198118022680626',
volume: 80,
playing: true,
connected: true,
paused: false,
shuffled: false,
loop: null,
autoPlay: true,
node: 'lavalink-replit-2.1lucas1apk.repl.co'
}
},
'voiceStates' => {
'990369410344701964': {
member: [Object],
user_id: '960185850346471505',
suppress: false,
session_id: 'e6bbd949edf477b2c228a6a2dc238125',
self_video: false,
self_mute: false,
self_deaf: false,
request_to_speak_timestamp: null,
mute: false,
guild_id: '990369410344701964',
deaf: false,
channel_id: '1089198118022680626'
}
},
'voiceServer' => { '990369410344701964': { event: [Object] } },
'current' => {
'990369410344701964': {
encoded: 'QAAAqwMAElJpaGFubmEgLSBEaWFtb25kcwAHUmloYW5uYQAAAAAABFF4AAtsV0EycGpNanBCcwABACtodHRwczovL3d3dy55b3V0dWJlLmNvbS93YXRjaD92PWxXQTJwak1qcEJzAQA0aHR0cHM6Ly9pLnl0aW1nLmNvbS92aS9sV0EycGpNanBCcy9tYXhyZXNkZWZhdWx0LmpwZwAAB3lvdXR1YmUAAAAAAAAAAA==',
identifier: 'lWA2pjMjpBs',
title: 'Rihanna - Diamonds',
author: 'Rihanna',
url: 'https://www.youtube.com/watch?v=lWA2pjMjpBs',
duration: 283000,
position: [Getter],
isSeekable: true,
isStream: false,
sourceName: 'youtube',
requester: null,
artworkUrl: 'https://i.ytimg.com/vi/lWA2pjMjpBs/maxresdefault.jpg',
isrc: null,
thumbnail: undefined,
time: 1697810407823,
ping: 14
}
},
'previous' => {
'990369410344701964': {
encoded: 'QAAA2gMAOUNocmlzdGluYSBQZXJyaSAtIEEgVGhvdXNhbmQgWWVhcnMgW09mZmljaWFsIE11c2ljIFZpZGVvXQAPQ2hyaXN0aW5hIFBlcnJpAAAAAAAEZQAAC3J0T3ZCT1R5WDAwAAEAK2h0dHBzOi8vd3d3LnlvdXR1YmUuY29tL3dhdGNoP3Y9cnRPdkJPVHlYMDABA
1Lucas1.apk
1Lucas1.apk•2y ago
🤭 I'm finishing some school work, I'll be back soon
foreign-sapphire
foreign-sapphireOP•2y ago
have fun :)
MEE6
MEE6•2y ago
GG @LuLeu, you just advanced to level 1!
1Lucas1.apk
1Lucas1.apk•2y ago
What version of node are you using?
foreign-sapphire
foreign-sapphireOP•2y ago
v18.17.1
1Lucas1.apk
1Lucas1.apk•2y ago
Did you test the console on the map? console.log(client.moon.map) Just to see what comes back
foreign-sapphire
foreign-sapphireOP•2y ago
1 sec
Map(5) {
'sessionId' => '1qdgxl77mrclimeq',
'players' => {
'1163549643087544451': {
guildId: '1163549643087544451',
textChannel: '1163549643767025707',
voiceChannel: '1163549643767025708',
volume: 80,
playing: true,
connected: true,
paused: false,
shuffled: false,
loop: null,
autoPlay: true,
node: 'localhost'
}
},
'current' => {
'1163549643087544451': {
encoded: 'QAABKwMAIzEuIEJsdWUgU3dlZGUgLSBIb29rZWQgb24gYSBGZWVsaW5nAA9Kb2VsIEd1c3RhZnNzb24AAAAAAAKQQAALTnJJLVVCSUI4SmsAAQAraHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1OckktVUJJQjhKawEAm2h0dHBzOi8vaS55dGltZy5jb20vdmkvTnJJLVVCSUI4SmsvbWF4cmVzZGVmYXVsdC5qcGc/c3FwPS1vYXltd0VtQ0lBS0VOQUY4cXVLcVFNYThBRUItQUhPQllBQzBBV0tBZ3dJQUJBQkdISWdXaWc4TUE4PSZycz1BT240Q0xDalR1RmY5Q3RkN1dhU094Q0M0OEZpNWMtTEh3AAAHeW91dHViZQAAAAAAAAAA',
identifier: '6Ac4NVYYl2U73QiTt11ZKd',
title: 'Hooked On A Feeling',
author: 'Blue Swede',
url: 'https://open.spotify.com/track/6Ac4NVYYl2U73QiTt11ZKd',
duration: 172866,
position: [Getter],
isSeekable: true,
isStream: false,
sourceName: 'spotify',
requester: null,
artworkUrl: 'https://i.ytimg.com/vi/NrI-UBIB8Jk/maxresdefault.jpg?sqp=-oaymwEmCIAKENAF8quKqQMa8AEB-AHOBYAC0AWKAgwIABABGHIgWig8MA8=&rs=AOn4CLCjTuFf9Ctd7WaSOxCC48Fi5c-LHw',
isrc: null,
thumbnail: undefined,
time: 1697811335652,
ping: 0
}
},
'voiceStates' => {
'1163549643087544451': {
member: [Object],
user_id: '1163546969625591968',
... (cut for dc nitro)
}
},
'voiceServer' => { '1163549643087544451': { event: [Object] } }
}
Map(5) {
'sessionId' => '1qdgxl77mrclimeq',
'players' => {
'1163549643087544451': {
guildId: '1163549643087544451',
textChannel: '1163549643767025707',
voiceChannel: '1163549643767025708',
volume: 80,
playing: true,
connected: true,
paused: false,
shuffled: false,
loop: null,
autoPlay: true,
node: 'localhost'
}
},
'current' => {
'1163549643087544451': {
encoded: 'QAABKwMAIzEuIEJsdWUgU3dlZGUgLSBIb29rZWQgb24gYSBGZWVsaW5nAA9Kb2VsIEd1c3RhZnNzb24AAAAAAAKQQAALTnJJLVVCSUI4SmsAAQAraHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1OckktVUJJQjhKawEAm2h0dHBzOi8vaS55dGltZy5jb20vdmkvTnJJLVVCSUI4SmsvbWF4cmVzZGVmYXVsdC5qcGc/c3FwPS1vYXltd0VtQ0lBS0VOQUY4cXVLcVFNYThBRUItQUhPQllBQzBBV0tBZ3dJQUJBQkdISWdXaWc4TUE4PSZycz1BT240Q0xDalR1RmY5Q3RkN1dhU094Q0M0OEZpNWMtTEh3AAAHeW91dHViZQAAAAAAAAAA',
identifier: '6Ac4NVYYl2U73QiTt11ZKd',
title: 'Hooked On A Feeling',
author: 'Blue Swede',
url: 'https://open.spotify.com/track/6Ac4NVYYl2U73QiTt11ZKd',
duration: 172866,
position: [Getter],
isSeekable: true,
isStream: false,
sourceName: 'spotify',
requester: null,
artworkUrl: 'https://i.ytimg.com/vi/NrI-UBIB8Jk/maxresdefault.jpg?sqp=-oaymwEmCIAKENAF8quKqQMa8AEB-AHOBYAC0AWKAgwIABABGHIgWig8MA8=&rs=AOn4CLCjTuFf9Ctd7WaSOxCC48Fi5c-LHw',
isrc: null,
thumbnail: undefined,
time: 1697811335652,
ping: 0
}
},
'voiceStates' => {
'1163549643087544451': {
member: [Object],
user_id: '1163546969625591968',
... (cut for dc nitro)
}
},
'voiceServer' => { '1163549643087544451': { event: [Object] } }
}
now i use node lts
1Lucas1.apk
1Lucas1.apk•2y ago
And player.current returns null 🤔
foreign-sapphire
foreign-sapphireOP•2y ago
now current works strange but now the player sometimes crashed internally when looking up a spotify track. dont have the error currently but i can send it if it comes up again
1Lucas1.apk
1Lucas1.apk•2y ago
Yesterday I noticed this error, I'm going to add some missing ifs, I think it should solve it
foreign-sapphire
foreign-sapphireOP•2y ago
is there any reason why player.current is any?
1Lucas1.apk
1Lucas1.apk•2y ago
GitHub
moonlink.js/src/@Moonlink/MoonlinkPlayers.ts at v2 · 1Lucas1apk/moo...
MoonLink.js is a simple package for lavalink client, perfect for you to create your discord bot with songs, and very simple and easy to use. Support Server: https://discord.gg/xQq2A8vku3 - 1Lucas1...
1Lucas1.apk
1Lucas1.apk•2y ago
If you give console.log to player, what does it return?
foreign-sapphire
foreign-sapphireOP•2y ago
nono current is defined but it has the type any. why not just MoonlinkTrack | null?
foreign-sapphire
foreign-sapphireOP•2y ago
in your defined MoonlinkPlayer.d.ts current is defined as a any type. https://github.com/1Lucas1apk/moonlink.js/blob/v2/src/@Moonlink/MoonlinkPlayers.ts#L56
GitHub
moonlink.js/src/@Moonlink/MoonlinkPlayers.ts at v2 · 1Lucas1apk/moo...
MoonLink.js is a simple package for lavalink client, perfect for you to create your discord bot with songs, and very simple and easy to use. Support Server: https://discord.gg/xQq2A8vku3 - 1Lucas1...
MEE6
MEE6•2y ago
GG @LuLeu, you just advanced to level 2!
1Lucas1.apk
1Lucas1.apk•2y ago
I understand, the right thing would be public current: Record<string, any> | null; Because current it changes to a json, and then the class it had in it no longer exists, so it becomes Record<string, any> I will fix this in the next version

Did you find this page helpful?