If you are a streamer on Twitch or YouTube, having a bot that helps manage chat and provides useful commands is essential. Nightbot is one of the most popular chatbots for streamers, offering automation and custom commands. One of the most requested commands is !uptime
, which tells viewers how long your stream has been live. In this article, we will guide you step by step on how to create the !uptime
command in Nightbot for both Twitch and YouTube.
Why Use an !uptime Command?
The !uptime
command allows viewers to check how long your stream has been running without needing to ask you directly. This can improve engagement and interaction in your chat while reducing repetitive questions. It also helps moderators provide quick answers to viewers.
How to Add the !uptime Command to Nightbot
Nightbot does not have a built-in !uptime
command, so we need to create a custom command using an API that retrieves the uptime of your stream. Follow these steps to set it up:
Step 1: Open the Nightbot Dashboard
- Go to Nightbot’s official website.
- Log in with your Twitch or YouTube account.
- Click on Commands in the left menu.
- Click on + Add Command to create a new command.
Step 2: Set Up the Command
In the Command field, type:
!uptime
In the Message field, use one of the following API calls, depending on your streaming platform.
For Twitch Streams
Use the following API URL:
$(urlfetch https://decapi.me/twitch/uptime?channel=$(channel))
For YouTube Streams
Since YouTube does not provide a direct uptime API like Twitch, you can use a workaround by integrating a third-party service or manually informing viewers about the stream’s start time. Some services allow tracking YouTube live streams, but they require API keys and extra setup. Currently, Nightbot does not support a direct !uptime
command for YouTube like it does for Twitch.
Alternatively, you can use a manual workaround:
The stream started at: $(twitch $(channel) "stream started at %starttime%")
This command will work if your Nightbot is set up to recognize YouTube Live data correctly.
Step 3: Configure Command Options
- Userlevel: Set it to Everyone so that all viewers can use the command.
- Cooldown: Set it to around 5-10 seconds to prevent spam.
- Alias: Leave this field empty.
Step 4: Save and Test the Command
Click Submit to save the command. Now, go to your chat and type !uptime
to see if it works. If your stream is live, the bot should return a message like:
The stream has been live for 2 hours, 15 minutes.
For YouTube, since there is no direct API, you may need to manually update your command with your stream start time.
Troubleshooting Common Issues
If the !uptime
command does not work, try these solutions:
- Ensure the API URL is Correct: Double-check the URL in the command message.
- Check if Nightbot is Active: Make sure Nightbot is a moderator and has joined your chat.
- Test the API in a Browser: Paste the API URL into your browser and see if it returns valid data (for Twitch).
- Ensure Your Stream is Live: The command will not work if you are offline.
- For YouTube, Consider Alternative Methods: Since YouTube does not have a direct uptime API, consider manually setting the start time in a pinned message or using another bot with API integration.
Additional Customizations
If you want to customize the response, you can modify the message output. Here are a few variations:
Adding a Friendly Message
$(urlfetch https://decapi.me/twitch/uptime?channel=$(channel)) - Thanks for tuning in!
Adding Emojis
⏳ The stream has been live for $(urlfetch https://decapi.me/twitch/uptime?channel=$(channel)) ⏳
Using a Different Language
O streamer está ao vivo há: $(urlfetch https://decapi.me/twitch/uptime?channel=$(channel))
Adding the !uptime
command in Nightbot is a simple yet effective way to improve engagement and provide useful information to your viewers. By following the steps above, you can easily set up and customize this command for your Twitch or YouTube stream. If you have any issues, try troubleshooting using the tips provided.
For YouTube, since a direct API is not available, you may need to manually input the stream start time or use a third-party tool. Regardless of your platform, setting up !uptime
enhances the viewer experience and makes your chat more interactive.
Now that you have successfully added the !uptime
command, explore other custom commands to enhance your chat experience!
Photo by Yan Krukau