Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

403
Views
How can i get the current time of the song playing in discord.js

This is my code:

const user = message.mentions.members.first() || message.author


let spotify = user.presence.activities.filter(x => x.name == 'Spotify' && x.type == 'LISTENING')[0]
const sp = spotify.status
console.log(sp) 

Is there a way to get the current time of the song on spotify and display it in seconds/minutes.

if the current song is at the 23 sec. it will display 0:23 in the console.

Discord js v13.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can read currentTime from audio element

function logCurrentTime() {
  let audioElement = document.getElementById('audio')
  document.getElementById('currentTime').innerText = audioElement.currentTime
}
<body>
  <button onclick="logCurrentTime()">Click to log current time</button>

  <p id='currentTime'></p>
  <audio id="audio" controls autoplay src="http://commondatastorage.googleapis.com/codeskulptor-assets/Epoq-Lepidoptera.ogg" />
</body>

Ref :- MediaElement

about 4 years ago · Juan Pablo Isaza Report

0

Have a look a the documentation. In this case, spotify.timestamps.start will be the time the user started the activity (as a date).

PS: The docs are your best friend! If there's anything you're ever unsure about, go here!

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!