LiveLyrics communicates with Discord by sending HTTP PATCH requests directly to Discordβs user settings API. Each request replaces your custom status with the current lyric line, paired with a π΅ emoji. No Discord bot, OAuth flow, or Rich Presence socket is involved β LiveLyrics acts as your own account making changes on your behalf, authenticated with your personal user token.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/x-eon-max/LiveLyrics/llms.txt
Use this file to discover all available pages before exploring further.
Authentication
LiveLyrics uses a Discord user token β the credential your own Discord client uses to authenticate your account β rather than a bot token. This token is stored in theTOKEN variable near the top of LiveLyrics.py:
authorization header in every request. Unlike bot tokens, user tokens are passed without a Bearer prefix, matching the convention Discordβs own client uses:
The PATCH Request
Status updates are sent by theupdate_status() function, which issues a single PATCH request to the Discord user settings endpoint:
custom_status object accepts two fields:
textβ the string displayed as your status. LiveLyrics passes the current lyric line, capped at 128 characters (Discordβs limit for custom status text).emoji_nameβ the emoji rendered beside the status text. LiveLyrics always uses π΅ to signal that the status is music-related.
update_status() is called only when the current lyric line changes β when line != last_line in main(). If the same line is still active on the next loop iteration (because the playback position has not yet advanced past the next timestamp), no request is sent.
Rate Limiting and Efficiency
LiveLyrics is designed to be a light, low-overhead process:- Change-gated updates β
update_status()is only called on a lyric transition, not on every loop tick. A typical song has 30β60 lyric lines, so even a three-minute track generates fewer than 60 PATCH requests. - Fast loop, minimal CPU β the main loop sleeps 10 ms between iterations (
asyncio.sleep(0.01)), giving the event loop time to yield without introducing noticeable latency in lyric changes. If an unexpected error occurs during media retrieval, the loop instead backs off for 2 seconds (asyncio.sleep(2)) before retrying, avoiding a tight error spin.
Discord does not publish official rate-limit figures for the user settings endpoint. However, because LiveLyrics sends at most one PATCH request per lyric-line change, the update frequency is naturally bounded by the cadence of the lyrics themselves β typically one request every few seconds β which sits well within any reasonable threshold.
Error Handling
update_status() wraps the network call in a try/except block so that transient failures never bring down the main loop:
- Any
requests.RequestException(connection timeout, DNS failure, etc.) is logged with a timestamp and swallowed, allowing the next iteration to proceed normally. - HTTP 4xx responses β such as a
401 Unauthorizedcaused by an invalid or expired token β are detected beforeraise_for_status()and the full response body is logged, giving you the diagnostic detail needed to identify the problem.