npoqDocumentation

Default commands

These work the moment the chatbot is on. Each one can be given aliases, restricted to a role or switched off in Commands.

CommandWhat it doesRole
!pointsA viewer's point balanceEveryone
!levelCurrent levelEveryone
!xpXP progress to the next levelEveryone
!topLeaderboard of top viewersEveryone
!watchtimeTotal time watchedEveryone
!followageHow long they have followedEveryone
!followersChannel follower countEveryone
!uptimeHow long the stream has been liveEveryone
!commandsLists the commands they can runEveryone
!addcomAdds a custom commandModerator
!editcomEdits a custom commandModerator
!delcomDeletes a custom commandModerator
!activecomTurns a command on or offModerator
!usecomSets when a command worksModerator
!rolecomSets which role can run itModerator

Custom commands

Add commands from the panel, or straight from chat with !addcom.

In chat
!addcom discord Join us: discord.gg/example
!editcom discord Our Discord: discord.gg/example
!rolecom discord moderator
!usecom discord live
!delcom discord
Roles

everyone, subscriber, vip, og, moderator, owner

Availability

always, live, offline

Cooldowns

You can set a global and a per-user cooldown for each command; the command will not run again until it expires.

Variables

The one placeholder you can use in a command response is {sender}. For persistent data there are three kinds of variables, all reachable from the Advanced Editor too.

{sender}Who ran the command
Global variables

A single value (text) for the whole channel.

Counters

A numeric value; ideal for increment/decrement (e.g. death counter).

Viewer variables

A per-viewer value (stored per user).

Advanced editor

When a template isn't enough, write JavaScript. Return a string and the bot posts it; return nothing and it stays quiet.

  • You must define a Main function and return a value — that value becomes the command output.
  • Main can be async; use await with npoq and fetch calls.
  • Keep scripts short and fast; the response length is limited.
  • fetch supports only http/https URLs and returns text (string).

npoq — Global variables

npoq.getGlobalVar(name)Promise<string | null>Reads a global variable.
npoq.setGlobalVar(name, value)Promise<void>Writes a global variable.
npoq.deleteGlobalVar(name)Promise<void>Deletes a global variable.

npoq — Counters

npoq.getCounter(name)Promise<number | null>Reads a counter value.
npoq.setCounter(name, value)Promise<void>Sets a numeric counter value.
npoq.deleteCounter(name)Promise<void>Deletes a counter.

npoq — Viewer variables

npoq.getViewerVar(name, viewer)Promise<string | null>Reads a viewer's value.
npoq.setViewerVar(name, viewer, value)Promise<void>Writes a viewer's value.
npoq.deleteViewerVar(name, viewer)Promise<void>Deletes a viewer's value.
npoq.clearViewerVar(name)Promise<void>Clears the variable for all viewers.

sender — The command user

sender.usernamestringUsername of the viewer who ran the command.
sender.slugstringViewer's channel slug.

Built-ins

fetch(url, options?)Promise<string>HTTP/HTTPS request; returns the response as text.
console.log(...args)voidLogs to the editor test panel.
Math, JSON, Date, Object, Array …Standard JavaScript built-ins are available.
Win counterJavaScript
<script>
const Main = async () => {
  const wins = (await npoq.getCounter('wins')) || 0
  await npoq.setCounter('wins', wins + 1)
  return `${sender.username} → ${wins + 1} 🏆`
}
</script>
Dice roll (random)JavaScript
<script>
const Main = () => {
  const roll = Math.floor(Math.random() * 6) + 1
  return `${sender.username} 🎲 ${roll}`
}
</script>
Fetch from an APIJavaScript
<script>
const Main = async () => {
  const res = await fetch('https://official-joke-api.appspot.com/random_joke')
  const joke = JSON.parse(res)
  return `${joke.setup} — ${joke.punchline}`
}
</script>