Using a status message is a great way to show info about you. Discord, the most popular chat app for devs has some advanced status features. They include:
- Normal text messages
- Song playing on Spotify
- Game playing
- Streaming on Twitch
- And more!
My portfolio posandu.me has a status message that shows what I’m currently listening to on Spotify.
PS: It updates automatically when the song is changed.
In this post, I will show you how to add your discord status to your website. We won’t be using Discord’s API, but instead, we will be using a service called Lanyard. Lanyard is a service that allows you to get your discord status in JSON format. It is very easy to use and has a lot of features. Let’s get started!
Step 1: Join the Lanyard Discord server
The first step is to join the Lanyard Discord server. We need to do it because there is a bot that watches your status and updates the JSON file. You can join the server here. (You can mute the server if you want)
Step 2: Get your Discord ID
Head to your Discord settings and go to the “Advanced” tab. And enable “Developer Mode”. This will allow you to get your Discord user ID.
Now navigate to a server and locate your profile and right-click it.
Click on “Copy ID” and paste it somewhere. We will need it later.
Step 3: Test the API
Now get your ID and replace *** with it in the URL below.
https://api.lanyard.rest/v1/users/***
If everything worked fine, you should get the following JSON response.
? wow! That’s a lot of data. Let’s break it down.
spotify
- This is the song you are currently listening to on Spotify. If you are not listening to anything, it will benull
.listening_to_spotify
- This is a boolean value that tells you if you are listening to Spotify or not.discord_user
- This is your Discord user info.discord_status
- This is your Discord status. It can beonline
,idle
,dnd
, oroffline
.activities
- This is an array of activities you are doing. It can be a game, a stream, or a custom status.active_on_discord_(web/mobile/desktop)
- These are booleans that tell you if you are active on Discord on a specific platform.
Step 4: Create a mockup
Now that we have the API working, we can add it to our website. I will be using Next.js and Chakra UI for this tutorial. You can use any framework you want. But, I will be using this one because I’m familiar with it.
First, clone the Next.js template.
Install the dependencies and run the development server.
Edit the pages/index.tsx
file and add the following code.
Which will give us this.
Now we need to add the data which we will do in the next step.
Step 5: Adding the things
We get the data from the server and update the state. We will use the useEffect
and useState
hooks for this.
And edit the JSX to use the data.
Now open Discord and listen to some music on Spotify. You should see the following.
Make sure you have Spotify connected to your Discord account and that you have enabled the “Show currently playing game as a status message” option in your Discord settings.
So, that’s it! You can use this to show your Discord status on your website. You can also use this to show the status of your friends. Just replace the ID with the ID of your friend(make sure they are in the Lanyard server).
Conclusion
Thanks for reading this tutorial. I hope you learned something new. If you have any questions, feel free to ask them in the comments.