Best Custom Nightbot Commands For Twitch 2022

Streaming on Twitch can be a lot of work, but it’s also fun and rewarding. It takes time to get the hang of streaming, and even longer to learn how to use all the features that are available.

One popular Twitch add-on is an easy-to-use chatbot called Nightbot. There are so many commands for Nightbot that you could spend hours just trying them out!

I’m a small-time Twitch affiliate and also a moderator in a popular channel. After spending hours researching and creating different commands, I’ve come up with a list of the best custom Nightbot commands for Twitch.

You might be surprised to learn how some of these commands work. They go a lot further than just responding to user interaction – they can make your stream uniquely appealing and memorable.

Before we get into the commands, let’s take a quick look at what Nightbot is and how the commands work. This will give you a lot of insight if you want to get creative and invent your own commands.

This article contains banner ads and affiliate links. If you follow them and then make a purchase, I may receive a commission at no additional expense to you. Thanks for reading!

PureVPN

What is Nightbot and How Does it Work On Twitch?

If you’re new to streaming, the first question you might ask is: what is Nightbot? Nightbot is a chatbot that can be used to do many things from advertising any streamer affiliate programs you may be part of to shouting out your friends.

Nightbot offers several benefits for Twitch streamers, primarily chat moderation and commands . You can set the bot up to “automod” based on a few settings, including filtering out bad language or links.

That’s great for helping keep your chat in line with your channel’s values, but this article is going to focus on custom Nightbot commands and ideas you can use to get really creative with them.

custom twitch commands nightbot

Common Uses For Nightbot Commands

Commands respond to specific user input that triggers a message from the bot. Most Nightbot commands start with an exclamation mark, such as !socials, but you can also create commands that respond to normal input.

Here’s a non-inclusive list of commonly used Nightbot commands:

  • !shoutout or !so followed by a fellow streamer’s name. This command will bring up a link to the streamer’s channel so people can follow them.
  • !donate to bring up a link where you can support the streamer.
  • !socials or !social to bring up the streamer’s social media links
  • !quote to bring up a random quotation
  • !death or something similar to count the number of times a game character has perished

You may have noticed that Nightbot can do different things. It can respond with a link, respond with a customized link, respond with a random canned message, count… it can even tell you the weather!

Nightbot Code You Need To Know

If you’re going to use Nightbot in your channel (or if you mod for someone who does), you’re going to want to have the following information.

Adding a New Command and Editing Commands

You can use “!commands add [command]” and “!commands edit [command]” as well as “!commands delete [command name]” to accomplish the obvious actions, but there is also a far superior shorthand that accomplishes the same things:

  • !addcom to add
  • !editcom to edit
  • !delcom to delete

When adding or editing a command, you start with the command name (including an exclamation mark (!) if you are using one) and then include the entire message. When deleting, you can just use the command’s name.

Creating Mod-Only or Streamer-Only Commands

The key to managing certain chat features is making commands only accessible to the streamer and/or their mods. To establish the permitted user level, Nightbot acknowledges -ul=.

An example would be !addcom -ul=mod !shoutout. This prefix would only allow moderators to call the ensuing command. To only allow the streamer to use a command, notation is -ul=owner. For a complete list of user levels, consult the Nightbot documentation.

Tagging Yourself and Others With $(user) and $(touser)

As the heading above suggests, you can create Nightbot commands that target the user and the person they tag. In normal Twitch chat, you tag others using @username. In order to get Nightbot to tag someone, you use $(user) and $(touser).

$(user) will tag the person executing the command, and $(touser) will tag the FIRST PERSON who they tag in their message.

A common example is the !so (shoutout) command. Note that there are actually multiple ways you can set this command up. In my opinion the easiest is:

!addcom !so Please check out the wonderful streamer $(touser) at https://twitch.tv/$(touser)

Using JavaScript With Nightbot For Advanced Commands

I didn’t realize for a long time that most of the code used in advanced Nightbot commands is actually JavaScript. JavaScript (often called JS) is a scripting language used in a lot of applications including ordinary websites.

In order to evaluate JavaScript in a command, you must employ a $(eval ) command, in which all of the code goes in between “eval” and the closing bracket.

Now, chat messages on Twitch are limited to 300 characters, which would seriously limit what you could do with JavaScript *IF* it wasn’t possible to use external code.

twitch custom chat commands nightbot

How to Make Nightbot Count

Counting commands are among the most popular in some streams, especially for gamers who want to let the chat keep track of their in-game deaths or other events. I know one streamer who has a command that counts the number of times they’ve burped while live!

Count is actually super easy to invoke – you just use $(count) in the command where you want the number to go. Resetting or editing a count command is trickier, but still pretty simple.

In order to incorporate external code into your commands, you can use $(urlfetch json ). This looks like the following example:

!addcom !yourcommand $(eval $(urlfetch json LINK))

The above command would get Nightbot to reference the link included and return a command based on its content.

Please note that you can only call the content of a raw text file hosted on a public website.

Most web pages are full of different types of code including (but not limited to) HTML, CSS, and JavaScript. This would make it impossible for Nightbot to know what you wanted it to do.

A raw text file on the other hand contains no “hidden” code – it contains only text, which allows Nightbot to read the JavaScript it contains.

If you have your own website or hosting you can upload text files there, but there are several free options available. The most common one I see referenced online is a website called Pastebin. Personally, I prefer to use GitHub.

Either way, make sure you use the raw text link.

Examples of Awesome Nightbot Commands

I don’t want to brag, but I’ve created some pretty cool Nightbot commands in the past few months. That said, I’ve really only scratched the surface of what’s possible.

This is because I’m a very junior JavaScript user, and Nightbot doesn’t really read JavaScript perfectly. If you call a JavaScript file that uses standard vanilla JavaScript, there’s a good chance Nightbot will return an error.

To save you time, I’ve compiled a list of my favorite commands and ways to use them.

How to Create a Randomized Nightbot Command

Command randomizers are great – you can use them to pull random quotes or inspiration, or just say silly things when your chatters least expect it. Here’s an example for a common randomizer:

!addcom !slap $(user) has slapped $(touser) with a $(eval a=["a herring", "a codfish", "a trout", "a salmon", "a dolphin", "a swordfish"]a[Math.floor(Math.random()*a.length)])

I’m sure that looks confusing if you don’t know at least a little JavaScript, so I’ll break it down.

  • !addcom !slap $(user) has slapped $(touser) with a $(eval – we’ve seen this earlier. This part of the command tags both the user and the person they’re directing the slap at, and initiates the JavaScript evaluation.
  • a=[“a herring”, “a codfish”, “a trout”, “a salmon”, “a dolphin”, “a swordfish”] – this part of the command uses a variable (a) to call an array, which just means a list.
  • a[Math.floor(Math.random()*a.length)]) – this final section uses JS to randomly select one of the entries in the array. To briefly explain, it checks a.length which is the number of entries in the array, and then picks a random within that value.

You can also call an array from an external JS file, allowing you to use longer entries and nearly as many items as you please. I have a !scare command in my friend’s channel which uses two randomizers to create a “mad libs” style output about the user scaring whoever they target.

How to Create a Sequential Nightbot Command

Another cool way to use JavaScript arrays in Twitch commands is to call the data sequentially. This means that rather than picking a random entry from an array, Nightbot will work through the array in order.

I used a sequential command in my channel to create a !story command which tells a  story one sentence at a time. With a bit more coding, you could make something really cool like a Nightbot calendar.

Here’s my story command:

$(eval c=`$(count)`; a=$(urlfetch json URL; if(c<=a.length){a[c-1]} else{`The story is over, please use !resetstory if you'd like to hear it again!`};)

Again, I’ll break it down a piece at a time, so you can see how to make your own.

  • $(eval c=`$(count)`; – This section establishes the variable c as representing the count. Using this variable allows me to pass the count variable into my external JavaScript document. The semicolon is merely a breakpoint
  • a=$(urlfetch json URL; – This section calls a raw text document I have hosted on GitHub. All it contains is an array filled with pieces of a story.
  • if(c<=a.length){a[c-1]}  – This section declares that if c (the count variable) is less than or equal to the number of entries in the array, the output should be the next sequential entry in the array. We need to use c-1 rather than c because $(count) starts counting at 1, whereas JavaScript starts counting at 0.
  • else{`The story is over, please use !resetstory if you’d like to hear it again!`};) – This section states that the count is not less than or equal to the number of entries in the array, the ensuing message should be the output.

I then have the commands !resetstory, which starts the count back at 1, and !editstory, which allows me or a moderator to set the count to a specific number.

To add a reset command you need to use !addcom !yourresetcommand !yourcommandtobereset -c=0 – Mine, for example, was !addcom !reset !story -c=0.

To add an edit command, use !addcom !youreditcommand !yourcommandtoedit -c=$(query). Mine is !story -c=$(query).

As you probably noticed, -c is used to set the count. Reset simply sets it to 0, whereas $(query) sets it to a user input number.

How to Create a Conditional Nightbot Command

You can use JavaScript if/else statements to create conditional commands, and this is one of my favorite Nightbot tricks.

What’s a conditional command? It’s a command that returns different messages according to the input it receives.

I have one command in my channel that has 12+ custom greetings built into it. My friends and regular viewers can use the !hello command and get a customized greeting that no one else can trigger.

There are a couple of ways to create conditional scenarios with JS, but if/else is the easiest, at least to me. Here’s an example:

if (a == "TwitchName"){"Custom greeting for relevant user".}
else if (a == "OtherTwitchName"){"Other custom greeting for relevant user".}
else {"Generic greeting."}

The above code is almost exactly what I use to have Nightbot greet my friends by name. The part in brackets establishes the condition, and the part in curly brackets is the output message. To call this file you could use !addcom !yourcommand $(eval a=”$(user)” $(urlfetch LINK)).

Conclusion – This Article is Far From Finished

The article on how to create amazing Nightbot commands is far from finished. I’ve only scratched the surface of what you can do with a little code and Twitch commands, so stay tuned for regular updates to this post.

I’m currently obsessed with learning JavaScript, and the more I learn the more I’m able to apply to Nightbot. I look forward to sharing it all with you!

Streaming can be a great way to make money online, but only if you really commit to it. Of course that’s the same for most methods. Best of luck!

Harness the power of artificial intelligence

Jarvis logo robot head

I wrote this post with help from my AI writing assistant, Jarvis. Tap the button to get a free trial and take Jarvis for a spin!

Claim Free Trial

Join my community!

best affiliate programs for content creators

Want first access to my content and free additional resources? Tap the button to join my online community.

Join Now

About Alex

AI writing expert, digital and affiliate marketer - helping you build the business in your brain.

Leave a Comment

sixteen − eleven =