March 11, 2024
A while back, I made a command-line tool called discid. In short, it allows you to check a user's Discord status using the Lanyard API, which exposes your Discord presence and activities to a REST API, then returns that data in a JSON format. discid uses Lanyard to fetch this data, then provides the information in a neat format within the command line.
To install discid, install it through npm:
npm install -g discid
To check the user's status on Discord, run the following in the terminal, replacing [userID]
with the 18-character ID of the user you want to check the status of:
discid [userID]
To be able to get the user ID of someone, follow these steps below first:
Enable Developer Mode on Discord. You can do this by going to Settings (⚙️), scrolling to the Advanced tab, and checking the toggle.
Right click on a user's profile picture and click on the final option, which says 'Copy User ID'. This will copy the user's ID to your clipboard.
Go back to your command-line and run discid [userID]
, replacing [userID]
with the ID of the user you copied.
For example, if you had the user ID 514106760299151372 copied, run:
discid 514106760299151372
Depending on what the status of the user is, different information may appear. For example, this is what it could look like in one instance:
iinter (lunar) • 🟢 Online Listening To: It Ain't Hard to Tell by Nas on Illmatic • 3min 14sec left Playing: Visual Studio Code • 📂 site • 📝 using-discid.md (51, 4) • 44min 39sec Platform: Desktop Avatar URL: https://cdn.discordapp.com/avatars/514106760299151372/4b869d3c6104a6a29abb8a847cfdd6ad.png
Note
This will only work on user ID's that are in the the Lanyard Discord server.
More fields are supported and shown in the output, not just the ones shown in examples. The full list that can be displayed is as follows:
More specific details are also able to be shown for certain fields. For example, the time left on a song, activity/state details, and more.
Listening To: Juicy - 2005 Remaster by The Notorious B.I.G. on Ready to Die (The Remaster) • 1min 42sec left # Time left is calculated by doing (current time - end time). # Song name, artist, and album comes from other fields set in the 'activities' section, specifically in 'spotify:1'. Playing: osu! • Himeringo - Koitsubakihime [Another] • Clicking circles # 'Himeringo - Koitsubakihime [Another]' comes from the state details, which is set to the name and difficulty of the map by osu!. # 'Clicking circles' comes from the state text in the activities section. Watching: Netflix • Alya Sometimes Hides Her Feelings in Russian # 'Netflix' is the platform being used and is set as the name of the activity. # 'Alya Sometimes Hides Her Feelings in Russian' is the show name and is set as the state text.
--json
This will print the user's information in a formatted, syntax-highlighted JSON response.
This is fetched from https://api.lanyard.rest/v1/users/:user_id
, replacing :user_id
with the user ID you entered. You can see an example of this with the user ID 514106760299151372 below.
{ "kv": { "email": "hi@iinter.me", "location": "UK", "website": "https://iinter.me" }, "spotify": { "track_id": "7AE0NKbt0BemBF8wuC2uCG", "timestamps": { "start": 1718648406978, "end": 1718648514831 }, "album": "THE MOUSE & THE MASK", "album_art_url": "https://i.scdn.co/image/ab67616d0000b2736c3fb85147fcf2972923cf2d", "artist": "DANGERDOOM; MF DOOM; Danger Mouse", "song": "Vats of Urine" }, "discord_user": { "id": "514106760299151372", "username": "iinter", "avatar": "7899b6669d533ddbb71daba31c511770", "discriminator": "0", "bot": false, "clan": null, "global_name": "lunar", "avatar_decoration_data": null, "display_name": "lunar", "public_flags": 4194432 }, "activities": [ { "flags": 48, "id": "spotify:1", "name": "Spotify", "type": 2, "state": "DANGERDOOM; MF DOOM; Danger Mouse", "session_id": "3b0eb598df22c414a6b8920d8e9717f6", "details": "Vats of Urine", "timestamps": { "start": 1718648406978, "end": 1718648514831 }, "assets": { "large_image": "spotify:ab67616d0000b2736c3fb85147fcf2972923cf2d", "large_text": "THE MOUSE & THE MASK" }, "sync_id": "7AE0NKbt0BemBF8wuC2uCG", "created_at": 1718648598163, "party": { "id": "spotify:514106760299151372" } }, { "id": "733484c2f2178e27", "name": "osu!", "type": 0, "state": "Idle", "application_id": "367827983903490050", "assets": { "large_image": "373344233077211136", "large_text": "intter (rank #396,678)", "small_image": "373370493127884800", "small_text": "osu!" }, "created_at": 1718648584568 } ], "discord_status": "online", "active_on_discord_web": false, "active_on_discord_desktop": true, "active_on_discord_mobile": false, "listening_to_spotify": true }
--open
This option will open the user's Discord profile in your default web browser. You can see an example of this in action below:
Tip
This option works with any user ID on Discord, as long as it is valid!
--kv
Lanyard also has key-value pairs (KV for short) which allow a key-value store to be added to the response by the user. See here for how to add them to your own response.
Here is an example with the KV of 514106760299151372:
{ "kv": { "email": "hi@iinter.me", "location": "UK", "website": "https://iinter.me" }, // rest of response... }
With those key-value's set, here is the terminal output that you will get for this:
KV of iinter: # 514106760299151372 email: hi@iinter.me location: UK website: https://iinter.me
To end off, if you have found discid useful in any way, make sure to visit the GitHub repository here and give it a star to show your support! I appreciate it very much.