Nightbot → Discord
Nightbot can only make GET requests. Discord webhooks only accept POST. This relays one to the other.
Get a key
Already have one? Paste it below.
Your key
Shown once and stored only as a hash — copy it now. Anyone with this key can post to your webhook and read this log.
Discord webhook
Discord: Server Settings → Integrations → Webhooks → New Webhook → Copy URL.
Your Nightbot command
Paste in chat as a moderator. Twitch:
YouTube (the relay works out the uptime itself):
Chat log
| When | Channel | User | Uptime | Note | Status |
|---|
No clips yet. Run !clip in chat.
How to use this
- Generate a key. It appears once. Copy it somewhere safe — it is stored only as a hash, so it cannot be shown again.
- Create a Discord webhook. In Discord: Server Settings → Integrations → Webhooks → New Webhook. Pick the channel the timestamps should land in, then Copy Webhook URL. Paste it above and save.
- Add the command to Nightbot. Copy the command shown above and paste it into your stream chat as a moderator. Nightbot replies confirming the command was added.
- Use it. Anyone in chat types
!clip, optionally with a note:!clip that dodge was insane. The timestamp appears in Discord, and in the chat log above.
Why does this exist?
Nightbot can only make GET requests through $(urlfetch), and can only print back plain text under 400 characters. Discord webhooks only accept POST with a JSON body. The two cannot talk directly. This relay accepts the GET, makes the POST, and hands Nightbot a short line to say in chat.
What the command actually does
$(urlfetch ...) | Calls this relay and prints whatever it returns. |
key= | Identifies your account, so the relay knows which webhook to post to. |
$(querystring) | Whatever the viewer typed after !clip, URL-encoded by Nightbot. |
$(twitch $(channel) "{{uptimeLength}}") | Twitch only. How long you have been live. The variable is uptimeLength — uptime does not exist and silently returns nothing. |
$(eval encodeURIComponent(...)) | Twitch only. The uptime contains spaces, which break a URL. This encodes it. The quote nesting matters: single quotes outside, double inside. |
-cd=15 | A 15-second cooldown. Keep it — Discord webhooks allow 30 messages per minute. |
Your name and channel are not in the URL. Nightbot sends them as request headers and the relay reads them from there.
Twitch and YouTube work differently
Twitch gives Nightbot an uptime variable, so the command passes it along and the Discord post shows how far into the stream you were.
YouTube has no such variable — YouTube never exposed elapsed stream time to chat bots, so Nightbot cannot provide it. This relay looks it up instead, and gets something Twitch cannot: a clickable link that jumps straight to that moment in the video. It keeps working after the stream ends, because the archive keeps the same video ID.
If the person running this relay has not configured a YouTube API key, YouTube clips still post — just without the uptime and the jump link.
Something went wrong?
Nightbot throws away the response body whenever a server returns an error code, printing Remote Server Returned Code NNN instead. So this relay deliberately answers with a normal status and puts the real explanation in the text, which Nightbot then says in chat.
| Chat says | What to do |
|---|---|
| Unknown key | The key in your command matches no account. Re-copy the command above. |
| No key in the URL | The command lost its key= part, usually from an edit. Re-copy it. |
| No Discord webhook set yet | Paste your webhook URL above and save. |
| Discord rejected the message | The webhook was deleted or regenerated in Discord. Make a new one and save it. The log's Status column has Discord's exact error — hover it. |
| Too many timestamps | More than 20 clips in a minute on one key. Wait, and raise the command cooldown. |
Remote Server Returned Code 404 | The URL is wrong. It should end in /clip. |
About your key
The key is the only credential. Anyone who has it can post to your Discord webhook and read your chat log, so treat it like a password. Moderators who can list Nightbot commands can see it — that is unavoidable, since it lives in the command.
It is stored only as a SHA-256 hash, so it cannot be recovered or emailed to you. If you lose it, generate a new key and update your command. If it leaks, do the same — the old key keeps working until you stop using it, so also delete the old Nightbot command.