Skip to content
NotSoBot’s quarantine has been lifted, and tags are back!

On October 14th, Discord lifted NotSoBot’s quarantine, so it can be added to servers and used in DMs again. The tag system is back on too, with one big change: tags can no longer show media from outside links. To show an image or video in a tag, upload it with {attach} first, then use $FILE_1 as the URL in your embed or component. Discord’s own images, like avatars, emojis, and server icons, can still be used directly. Check out the tag documentation for examples, and the new tag directory for official verified tags. For questions, join our support server.

What happened

  1. August: Discord’s Developer Compliance team contacted us about content moderation in NotSoBot, including the tag system, .edit, and our AI image features. We replied on August 13th with the fixes we had made.
  2. August 18th: Discord asked us to formally certify those fixes by August 21st. We replied with our changes, but the reply was missing the formal certification they needed.
  3. Early September: Discord sent a follow-up with a September 4th deadline. We mistook it for a copy of the first notice and missed the deadline, and NotSoBot was quarantined.
  4. September 16th: We sent the full certification and asked Discord to review the quarantine.
  5. September 28th: Discord told us to remove the tag system by October 9th.
  6. October 1st: We responded with our new safety filters and asked to keep the tag system.
  7. October 9th: We disabled the tag system on the deadline to stay compliant.
  8. October 13th: Discord asked us to also certify that NotSoBot is protected against child safety and gore content, and that it contains no adult content. We made the changes below and sent the new certification.
  9. October 14th: Discord reviewed our certification and lifted the quarantine. We brought the tag system back with stricter media rules.

What we’ve changed

  • All NSFW-specific commands have been removed for good, along with commands featuring adult branding.
  • Every command now runs in safe mode everywhere, including age-restricted channels and DMs.
  • AI image commands like .imagine, .edit, .reimagine, and .mashup can’t produce sexual content in any channel.
  • Every media command scans its output before posting, and all media is checked for NSFW content, gore, and child safety in every channel. If a scan fails, the output is blocked.
  • NSFW detection uses two models we run locally on our own servers, ShieldStral and NudeNet. Content flagged by either one is blocked.
  • Prompts, search queries, and text output are checked against Discord’s Community Guidelines, and are blocked if the check fails.
  • Files produced by the code runner are scanned for NSFW content, gore, and child safety in every channel.
  • Search commands like .image now download, scan, and upload results instead of posting a link.
  • Results from sources with user-written content, like Reddit, 4chan, and Urban Dictionary, are filtered or scanned before they’re shown. Flagged results are hidden.
  • Tags can no longer show media from outside links. Embeds and components can only show files the tag uploaded through NotSoBot, or Discord’s own images like avatars and emojis.
  • All tag text is checked against Discord’s Community Guidelines, including text inside embeds, buttons, menus, and other components.
  • Flagged content is logged to a review queue, and repeat offenders are flagged and dealt with.
  • There is now a report system: use /bot report to report a user or server abusing NotSoBot to the developers.
Documentation

Tag Scripting

Tags are saved messages that can do much more than reply with text. Use these 222 functions to read arguments, store data, edit images, call APIs, and build interactive replies.

On this page

What are tags?

A tag is a saved message you can bring back with a short name. Tags can be plain text, but they can also contain TagScript: little {functions} in curly brackets that run every time the tag is shown. That lets one tag greet whoever used it, pick a random answer, remember a score, fetch an image or even run Python.

Create a tag with .tag create <name> <content> and show it with .tag <name> (or the shorter .t <name>, or /tag show). Anything you type after the tag name is passed to the tag as its arguments. Tag names with spaces go in quotes, like .tag create "my tag" hello!.

Change a tag with .tag edit <name> <new content>, and see its raw source with .tag raw <name> (an alias of .tag info). Server managers can turn a tag into a custom command with .tag commands add <name>, so members can run it directly as .<name>.

If you create a tag with no text but attach a file to the message, the tag is saved as {attach:URL} so the file is sent every time the tag runs.

.tag create greet Hello {user}, welcome to {server}!
→Creates a tag named greet.
.tag greet
→Hello cake, welcome to NotSoBot Support!

Syntax

A function is written as {name} or {name:argument}. The name ends at the first :, and everything after it, up to the matching }, is the argument. Function names are not case sensitive, so {UPPER:hi} and {upper:hi} are the same.

Functions that take several arguments separate them with |, like {range:1|10}. A | inside a nested function does not split the outer one, so {choose:a|{upper:b|c}} has two choices, not three.

Functions can be nested. For most functions the argument is evaluated first (inside-out), and the function then works on the finished text: in {upper:{user}}, {user} becomes cake and then upper turns it into CAKE.

Some functions evaluate their arguments lazily instead, only running the parts they actually need: if, and, or, iferror, choose, foreach, set and get (in every storage scope), includes, indexof, substring, setfilename, componentjson, componentsontimeout and evalsilent. This is why {if} only runs the branch that matches, and {choose} only runs the option it picked.

Whitespace just inside the brackets is trimmed, so { user } works, but the name itself must be written without spaces before the : ({upper :hi} is not recognised). Plain arguments are trimmed too.

If a name is not a known function, or a function is given arguments it cannot use, the text is left in the output as it was written (with any nested functions already filled in). A { without a matching } is also output as plain text.

{upper:{user}}
→CAKE
{choose:{set:prize|gold}|{set:prize|silver}}You won {get:prize}!
→You won gold! (or silver; only the chosen set runs)
Hi {notafunction:{user}}
→Hi {notafunction:cake}

Escaping and comments

To output TagScript without running it, wrap it in {ignore:...}. The argument is printed exactly as written and nothing inside it is evaluated. Its brackets still need to be balanced.

{note:...} is a comment: its contents are never evaluated and nothing is output, which is handy for leaving yourself notes in long tags.

To print a single symbol that would otherwise be read as syntax, use the insert functions: {bracketleft} for {, {bracketright} for }, {splitterargument} for |, {splitterfunction} for : and {newline} for a line break. Each accepts a count, like {newline:3}.

A backslash \ before {, } or | escapes it. In the tag's own text (outside any function) the backslash is removed and the character is printed as-is, so \{user} outputs {user} without running it. Inside a function's argument, \{ and \} stop a bracket from opening or closing a function and \| stops a | from splitting arguments, but the backslash before a bracket stays in the output there, so {ignore} and the insert functions are usually cleaner inside functions.

Keep in mind that the insert functions produce real characters: when used inside a function that evaluates its argument first, an inserted | is seen by that function as a separator.

{ignore:Use {user} to show your name!}
→Use {user} to show your name!
{note:this part is just for me}Hello!
→Hello!
{bracketleft}user{bracketright} is {user}
→{user} is cake

Arguments

Everything typed after the tag name becomes the tag's arguments. {args} returns all of it as typed, and {arg:N} returns a single argument by position, starting from 0 ({arg} alone is the first one). Negative positions count from the end, so {arg:-1} is the last argument. {argslen} returns how many arguments there are, and {args:start|end} returns a range joined with spaces.

Arguments are split on spaces. Wrapping words in quotes keeps them together as one argument, so .tag rate "pizza with pineapple" has one argument. Straight quotes and most curly and international quote pairs work.

Arguments are inserted into your tag as text, so if someone types a | it can be read as a separator by the function it ends up in. {argsafe} and {argssafe} work like {arg} and {args} but escape any | first.

When one tag runs another with {tag:id|arguments}, the inner tag gets its own arguments, and the outer tag's arguments are restored when it finishes.

.tag create rate {arg} is a {range:1|10}/10
→Creates a tag that rates its first argument.
.tag rate "pizza with pineapple"
→pizza with pineapple is a 7/10
You gave {argslen} arguments, the last one was {arg:-1}
→With arguments a b c: You gave 3 arguments, the last one was c

Variables and storage

Variables let a tag remember values while it runs. {set:name|value} stores a value and {get:name} reads it back. {get:name|fallback} returns the fallback when the variable was never set, and {delete:name} removes it. Values are trimmed when stored.

Variables only last for a single run of the tag (and any button clicks on that same message). A tag can have up to 100 variables, names can be up to 64 characters, and values longer than 1 MB are cut off.

Names starting with __ are reserved for the engine's own private variables, so they cannot be set or deleted, though some can be read with {get}: {get:__args} gives the parsed arguments as a JSON array, {get:__argsString} the arguments exactly as typed, and {get:__files} a JSON list (filename and description) of the files attached to the reply so far.

To keep data between runs, use persistent storage. There are four scopes, each with its own set, get and delete functions: user ({setuser}, {getuser}, {deleteuser}) is separate for every person, channel ({setchannel}...) for every channel, server ({setserver}...) for every server (in DMs, the DM channel counts as the server), and global ({setglobal}, {getglobal}) is shared by everyone who uses the tag anywhere.

Storage belongs to the tag, so two different tags never see each other's data, while aliases of a tag share it. Storage only works when running a saved tag. Storage keys can be up to 128 characters and values up to 16,384 characters. Each scope holds at most 5 keys; saving a 6th errors, and saving an empty value deletes a key. {variablesuser}, {variableschannel}, {variablesserver} and {variablesglobal} return a scope's stored keys and values as JSON.

Code run from a tag (Python, Node.js, Bun and Lua) can read and change variables and storage too, through the discord object. Code also has access to blobs: one larger value per scope (user, channel, server and global), up to 256 KB each, that only code can read and write. The same 5-keys-per-scope limit applies whether storage is written by {setuser} and friends or from code. See "The discord object" for the details.

In short: variables hold up to 1 MB each and are cleared after every run, storage values hold up to 16,384 characters each and are kept between runs, and blobs hold up to 256 KB each and are kept between runs.

{set:food|pizza}I love {get:food}!
→I love pizza!
{setuser:count|{math:{getuser:count|0}+1}}You have used this tag {getuser:count} times.
→You have used this tag 5 times.
Hi {get:nickname|stranger}
→Hi stranger

Conditions

{if:value|operator|value|then:...|else:...|finally:...} compares two values and runs the matching branch. then:, else: and finally: can come in any order and any of them can be left out (at least one is needed). Only the branch that matches is evaluated; finally: is always evaluated afterwards and added after it.

Both values are evaluated first, then compared. Write the operator with no spaces around it (|=|, not | = |), otherwise it is not recognised and the whole {if} is output as text. Spaces left around the values also count as part of them.

= and != compare text exactly, including upper and lower case. >, >=, < and <= compare numbers (decimals are fine, and an empty value counts as 0); if either value is not a number, the comparison is false. ~ is a loose equals: numbers are compared by value, so 1.50 matches 1.5, and anything else is compared as text ignoring case, so Yes matches yes. ? treats the second value as a regex and checks if it matches anywhere in the first value, ignoring case (use ^ and $ to match the whole thing, and \| for a literal | in the regex).

For combining checks, {and:a|b|c} runs each part in order and stops at the first one that comes out empty. If none are empty it outputs the last part. {or:a|b|c} outputs the first part that is not empty. Both run left to right and skip the rest once they have an answer. With a single part (no |), {or} simply evaluates and outputs it.

OperatorMeaningCompares
=EqualText, exact match
!=Not equalText, exact match
>Greater thanNumbers
>=Greater than or equalNumbers
<Less thanNumbers
<=Less than or equalNumbers
~Loosely equalNumbers by value, otherwise text ignoring case
?Regex matchText, against the regex in the second value, ignoring case
{if:{arg}|~|yes|then:Great!|else:Oh no...}
→With argument YES: Great!
{if:{range:1|100}|>|90|then:Critical hit!|else:You hit.}
→Critical hit! (about 1 in 10 times)
{or:{get:nickname}|{user}}
→The saved nickname, or your username if none is set.

Running code

Tags can run real code in a sandbox: use a programming language as the function name, like {python:print("hi")} or {js:console.log(1 + 1)}. Whatever the program prints is added to the tag's output at that spot, so code and normal TagScript can be mixed freely.

The code can also be wrapped in a `` code block inside the function ({python:``py ... `}). The language written after the opening backticks is ignored; the function name decides the language. An empty function does nothing.

Language names are not case sensitive, and the internal names work too ({node:...}, {golang:...}, {c_plus_plus:...}). A specific version can be requested after a dash, like {python-3.12.16:...} or {node-26.13.1:...}; it has to be one of the versions in the table, written in full. A version that has since been replaced by a newer patch still works and runs the newer one. Without one, the default version is used.

Each code run counts as one network request (files loaded with load lines do not cost extra). In a saved tag, code that mentions storage or blob anywhere also loads the tag's storage and blobs first, which costs 2 more, and saving changes back costs 1 more for each. Other tags cannot be run from inside code: a {tag} inside a code function is left as plain text.

The table lists every language and the names you can call it by. Python, Node.js, Bun and Lua also get a ready-made discord object with the tag's context, variables and storage (see "The discord object" below).

LanguageNames you can useNotes
Bashbash, sh, zshffmpeg, ImageMagick and libvips are installed.
Brainfuckbrainfuck, bf
BunbunVersion 1.4.3. Runs JavaScript and TypeScript, with the same packages and discord object as Node.js.
Cc, c(gcc), hVersions 17.0.0 (C17) and 23.0.0 (C23, default).
C++c++, cpp, c++(gcc), h++, hpp, cxx, hxx, cc, hhVersions 20.0.0 (C++20), 23.0.0 (C++23, default) and 26.0.0 (C++26).
C#c#, cs, csharp.NET 10.0.15.
CoffeeScriptcoffeescript, coffee, cson, iced
COWcow
Dd
Dartdart
DenodenoNo discord object.
Elixirelixir, ex
Emojicodeemojicode, emoji
Erlangerlang, erl
Fortranfortran, fort, f90, f95
gojqgojq
Gogo, golang
Javajava, jspVersions 25.0.5 and 27.0.1 (default).
Kotlinkotlin, kot, kt
LOLCODElolcode, lol
LualuaVersions 5.4.9 and 5.5.1 (default), with dkjson and base64. Has the discord object.
NASM (32-bit)nasm, nasm32, asm, assembly
NASM (64-bit)nasm64, asm64, assembly64
Node.jsjavascript, js, node.js, node, jsxVersions 22.23.5, 24.22.3 and 26.13.1 (default). Has the discord object.
Perlperl, pl, pm
PHPphp
Prologprolog, pro
Python 3python, python3, py, py3Versions 3.11.18, 3.12.16, 3.13.18, 3.14.10 (default) and 3.15.2. Has the discord object.
Python 2python2, python2.7, py2.7, py2Version 2.7.18. Has the discord object.
Rubyruby, rb
Rustrust, rs
SQLitesqlite3, sqliteRuns the code as SQL in a fresh in-memory database.
Swiftswift
TypeScripttypescript, tsSame packages as Node.js, but no discord object.
{python:print("Hello from Python, {user}!")}
→Hello from Python, cake!
{js:console.log(Math.round(Math.random() * 100))} is your score
→42 is your score
{python-3.12.16:import sys; print(sys.version.split()[0])}
→3.12.16

TagScript inside code runs first

Before your code is sent to the sandbox, the whole argument is evaluated as TagScript. That is handy, because {python:print("{user}")} prints your username, but it also means every {...} in your code is read as a possible TagScript function.

Curly brackets are everywhere in code: Python dicts, sets and f-strings, JavaScript objects, blocks and ${} templates, and the bodies of C, Java, Rust and Go functions. If the text inside the brackets happens to match a function name ({name}, {id}, {user}, {text}, {e}, {pi}, {args}...) it gets replaced, and the program breaks in confusing ways. Brackets that do not match a function name are left alone, but anything inside them is still evaluated and can use up the iteration limit.

The fix is to wrap the code in {ignore:...}, which passes it through exactly as written. You can keep the TagScript parts you want outside of the {ignore}, for example load lines or a value you insert at the top. The brackets inside {ignore} still have to balance, so a lone { inside a string should be written another way (like chr(123) in Python).

To pass user input into code safely, insert it with {jsonify:...}. It turns any text into a quoted, escaped string literal that is valid in both Python and JavaScript, so quotes or newlines in the input cannot break your code.

{js:{ignore:const data = {a: 1, b: [1, 2]}; console.log(JSON.stringify(data));}}
→{"a":1,"b":[1,2]}
{python:name = {jsonify:{args}}
{ignore:print(f"Hello {name}, your name has {len(name)} letters")}}
→With arguments Ana "the great": Hello Ana "the great", your name has 15 letters
{python:name = "Bob"; print(f"Hi {name}")}
→Hi cake (not Bob): {name} is a TagScript function, so it was replaced with your username before Python ran. Wrapping the code in {ignore} fixes it.

What code can use

Every run starts in a fresh, empty sandbox with its working folder at /home/notsocoder. Nothing is kept between runs except what you save through the discord object's storage, blobs and variables.

Code has internet access, limited to about 20 Mbps and 3 requests per second, so it can call web APIs (for example with requests in Python or fetch in Node.js). A run can take about 15 seconds before it is stopped, a bit longer for premium users.

The command line tools ffmpeg, ffprobe, ImageMagick and libvips (vips, vipsthumbnail) are installed for every language, so even a {bash} tag can convert media. The packages in the table below come preinstalled; nothing else can be installed.

Anything a program writes to its error output (stderr) stops the tag with that text as the error, even if it is only a warning. Silence warnings or log to stdout instead. The one exception is ffmpeg, which prints its version banner to stderr even when it works: if the error output starts with that banner or mentions Input, the tag carries on as long as the program produced output files. Passing -hide_banner -loglevel error to ffmpeg avoids the problem entirely.

LanguageThird-party packages
Python 3numpy, scipy, pandas, whoosh, bcrypt, passlib, sympy, pillow, wand, pyvips, aiohttp, requests, ffmpeg-python, beautifulsoup4, matplotlib, yfinance, moviepy, networkx, opencv-python, primp, pydub, numba, redis, librosa, torch, pyyaml
Python 2numpy, scipy, pycrypto, whoosh, bcrypt, passlib, requests
Node.js, Bun, TypeScriptjssoup, mathjs, imagescript, sharp, node-fetch, undici, redis, canvas
Luadkjson, base64
{python:import requests
r = requests.get("https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd")
print("Bitcoin is $" + str(r.json()["bitcoin"]["usd"]))}
→Bitcoin is $67000
{python:{ignore:import warnings
warnings.filterwarnings("ignore")
import pandas as pd
print(pd.Series([3, 1, 2]).sort_values().tolist())}}
→[1, 2, 3] (warnings are silenced so they cannot stop the tag)

What code sends back

Text printed to stdout is added to the tag's output, with surrounding whitespace trimmed. Printed text up to 16,000 characters is checked for JSON (embeds, components, pages); longer text is always added as plain text. The finished message is still cut to the normal message length.

If the program prints a single JSON object, a few keys are turned into real message parts instead of text:

  • embed (one embed object) and embeds (a list of them) add embeds, up to 10 in total.
  • components (a list of buttons, select menus or action rows, in the same format as {componentjson}) adds components; an optional componentsOnTimeout string is TagScript to run when they expire.
  • pages adds paginator pages in the same format as {pagejson}, but only when it is the object's only key.

When the JSON has embed, embeds or components, none of the printed text is shown, and other keys (like content) are ignored. Print a normal line of text, or use {embedjson} outside the code, if you need both.

Files the program saves into /home/notsocoder/output (or ./output) are attached to the reply, up to 10 per run. Files larger than the channel's upload limit are skipped, and the reply as a whole can still only carry 10 attachments. Output images and videos go through the same content filter as other media, so NSFW results are blocked outside NSFW channels. These files can be passed on to later code, {ai} or MediaScript with load FILE_X (see "Loading files with load").

{python:{ignore:import json
print(json.dumps({"embed": {"title": "Hello from Python", "color": 5793266}}))}}
→A blurple embed titled "Hello from Python" (the JSON itself is not shown).
{python:{ignore:import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
plt.plot([1, 4, 2, 5])
plt.savefig("/home/notsocoder/output/chart.png")}}
→A line chart attached as chart.png.
{bash:seq 1 5000 > ./output/numbers.txt; echo done}
→done, with numbers.txt attached.

The discord object

In Python (3 and 2), Node.js (JavaScript), Bun and Lua, a global discord object holds the context of the tag run. In Python it is a dict (discord["user"]["id"]), in Node.js and Bun an object (discord.user.id) and in Lua a table (discord.user.id). Deno, TypeScript and the other languages do not get it.

Most fields are read-only snapshots: changing them does nothing. Only variables, storage and blobs are written back when the program exits normally. In Node.js that happens on the beforeExit event, so calling process.exit() or crashing skips saving; in Python it happens at exit, so os._exit() skips it. Changing the working folder can also stop the save from being found.

storage and blobs are only loaded when the code contains the word storage or blob (in any case, even in a comment). Otherwise they arrive empty and nothing written to them is saved, the same as code run outside a saved tag.

variables contains the tag's variables at the moment the code started (including private ones like __args and __files). After the run, every key that does not start with __ is set as a TagScript variable, converted to text and cut to 1 MB, following the usual variable rules (names up to 64 characters, up to 100 variables). Removing a key in code does not delete the TagScript variable; use {delete} for that.

storage holds the tag's persistent storage for the current user, channel, server and global scopes, the same data {getuser}, {getchannel}, {getserver} and {getglobal} read. Each scope is written back as a whole: keys you delete are removed, and setting a scope to {} (or None/null in Python and Node.js) clears it. Values are saved as text: a number 5 becomes "5", and a dict, list or object is saved as its JSON text (parse it again when you read it back).

Storage written from code has extra rules: each scope can hold at most 5 keys, keys can be up to 128 characters and values up to 16,384 characters. Breaking one stops the tag with an error. {setuser} and friends enforce the same 5-key limit, so storage written outside code can never block a code run. Empty values do not count toward the limit.

blobs hold one larger value per scope (user, channel, server, global), up to 256 KB each, and can only be used from code. A blob arrives as bytes in Python, a Buffer in Node.js and a string in Lua, or as None/null when empty. You can assign bytes, a string, or any other value (which is saved as JSON text); set it to None/null to clear it. In Lua, setting a blob or storage scope to nil keeps the old value, so assign an empty string or table instead.

Storage and blobs only exist when running a saved tag. Aliases share their main tag's data. When code runs outside a saved tag, both start empty and changes are thrown away.

FieldWhat it holdsWritable
userThe user who ran the tag (id, username, avatar...).No
memberThat user's server member data (nick, roles, joined_at...). Null outside servers.No
channel / channel_idThe channel the tag ran in, and its id.No
guild / guild_idThe server and its id. Null in DMs. On servers with more than 10,000 members, only the bot, the user and members in voice are included.No
messageThe message that ran the tag. Null for slash commands and button clicks.No
tagThe saved tag: id, name, content, uses, nsfw, locked, created, edited, user (the owner) and more. Null outside saved tags.No
user_bot / member_botThe bot's own user and member data.No
variablesThe tag's variables. Keys not starting with __ are copied back as TagScript variables.Yes
storageuser, channel, server and global objects of persistent key/value storage.Yes
blobsuser, channel, server and global binary values, up to 256 KB each.Yes
{python:discord["variables"]["lucky"] = 7}Your lucky number is {get:lucky}
→Your lucky number is 7
{python:{ignore:s = discord["storage"]["user"]
s["runs"] = str(int(s.get("runs", "0")) + 1)
print("You have run this tag", s["runs"], "times")}}
→You have run this tag 3 times (the count is the same one {getuser:runs} reads)
{python:{ignore:import json
raw = discord["blobs"]["global"]
ids = json.loads(raw) if raw else []
if discord["user"]["id"] not in ids:
    ids.append(discord["user"]["id"])
discord["blobs"]["global"] = json.dumps(ids)
print(len(ids), "different people have used this tag")}}
→12 different people have used this tag
{js:{ignore:console.log(`${discord.user.username} is in #${discord.channel.name}`)}}
→cake is in #general

Files in code

Files you hand to the program with load lines (explained in the next section) are saved in /home/notsocoder/input (also reachable as ./input), using the filename you gave or the one from the download. Filenames are cleaned up, so spaces and unusual characters may be replaced. Up to 10 files can be loaded into one run.

Each loaded file's full path is also put in an environment variable: FILE_1, FILE_2 and so on. Read it with os.environ["FILE_1"] in Python, process.env.FILE_1 in Node.js or $FILE_1 in Bash. This numbering only counts the files loaded into this one run, and it is separate from the FILE_X numbers used in load lines.

The environment variables are numbered with files reused from earlier in the tag (load FILE_X) first, then files downloaded from web URLs, each group in the order of its load lines. If you only load one kind, that is simply the order of the lines. When mixing both, giving each file a name and opening it from /home/notsocoder/input/NAME avoids any confusion.

Anything saved to /home/notsocoder/output (or ./output) is attached to the reply when the program ends. Do not try to {attach} those paths; they only exist inside the sandbox.

{python:load {avatar} avatar.png
{ignore:import os
print(os.environ["FILE_1"], os.path.getsize(os.environ["FILE_1"]), "bytes")}}
→/home/notsocoder/input/avatar.png 48213 bytes
{bash:load {iv}
ffmpeg -hide_banner -loglevel error -i "$FILE_1" -vf negate "./output/$(basename "$FILE_1")"}
→The last image or video in chat with its colors inverted.

Loading files with load

Code, {ai} and MediaScript can all be given files by starting their content with load lines. In code and {ai}, the line is load URL or load URL FILENAME; in MediaScript it is load URL MEDIA_KEY, where the third word names the media inside the script.

The rules for code and {ai}:

  • Put one load line per file at the very top, before any other code or text. Blank lines between them are fine.
  • The first line that is not a load line ends the list, and everything from there on is your code or prompt. A load line further down is just treated as code.
  • The URL cannot contain spaces, and anything after ## on a load line is a comment. load is not case sensitive.
  • The URL is usually TagScript, like {image}, {avatar} or {iv}, which is filled in before the code runs.
  • Give each file a different name: two load lines with the same filename keep only the last one.

Instead of a web URL you can write FILE_X to reuse a file that this run of the tag already produced: anything added by {attach}, {attachtext}, {mediascript}, or files written by earlier code. FILE_1 is the first file currently attached to the reply, FILE_2 the second, and so on, in the order they were added. {get:__files} shows the current list if you are unsure.

FILE_X moves the file: it is handed over and removed from the reply's attachments, which is what you want when the file was only an in-between step. FILE_X_COPY hands over a copy and leaves the original attached. A file loaded with FILE_X keeps its filename unless you give a new one.

Because FILE_X removes files, the numbers of the files after it move down once the function finishes. If the reply has files 1, 2 and 3 and code loads FILE_1, the old file 2 is FILE_1 for the next function. Within a single function all the numbers refer to the list as it was before that function started, so load FILE_1 and load FILE_2 together grab the first two files. New output files are added to the end of the list.

In MediaScript, FILE_X and FILE_X_COPY work the same way but are replaced anywhere in the script, not only in load lines.

WriteWhat happens
load https://...Downloads the URL and passes it in (named after the download).
load https://... name.pngSame, saved as name.png.
load FILE_2Passes in the 2nd file attached so far and removes it from the reply.
load FILE_2_COPYPasses in the 2nd file attached so far and keeps it in the reply.
load FILE_2 new.pngMoves the 2nd file in, renamed to new.png.
{python:load {image} input.png
{ignore:import os
from PIL import Image, ImageOps
img = Image.open(os.environ["FILE_1"]).convert("RGB")
ImageOps.invert(img).save("/home/notsocoder/output/inverted.png")
print("Inverted!")}}
→Inverted! with the last image in chat attached as inverted.png, colors inverted.
{python:load {avatar} left.png
load {avatar:{arg}} right.png
{ignore:from PIL import Image
a = Image.open("/home/notsocoder/input/left.png").convert("RGBA").resize((256, 256))
b = Image.open("/home/notsocoder/input/right.png").convert("RGBA").resize((256, 256))
out = Image.new("RGBA", (512, 256))
out.paste(a, (0, 0))
out.paste(b, (256, 0))
out.save("/home/notsocoder/output/versus.png")}}
→With argument @friend: your avatar and your friend's side by side.
{ai:load {image}
Describe this image in one short sentence.}
→The AI's description of the last image in chat (uses your one {ai} call).
{mediascript:load {iv} media
invert media
render media image/png}
{python:load FILE_1 inverted.png
{ignore:from PIL import Image
img = Image.open("/home/notsocoder/input/inverted.png")
print(f"The inverted image is {img.width}x{img.height}")}}
→The inverted image is 512x512. The MediaScript result was moved into Python, so it is not attached.
{python:{ignore:from PIL import Image
Image.new("RGB", (256, 256), "red").save("/home/notsocoder/output/red.png")}}
{mediascript:load FILE_1 square
spin square
render square}
→Python makes a red square, MediaScript spins it, and only the spinning GIF is sent.
{attach:https://cdn.nsb.gg/assets/samples/b1.png|b1.png}
{python:load FILE_1_COPY
{ignore:import os
print("b1.png is", os.path.getsize(os.environ["FILE_1"]), "bytes")}}
→b1.png is 39702 bytes, with b1.png still attached because of _COPY.

Settings

{settings:SETTING|value} changes how the rest of the tag behaves. Setting names are not case sensitive. Settings only affect the current run and apply to functions that run after them, so put them at the start of the tag.

Spaces around the setting and value are ignored, and an empty value clears a setting. An unknown setting name, or a call without exactly one |, is left in the output as text.

SettingValueWhat it does
AI_MODELA model name, e.g. ANTHROPIC_CLAUDE_HAIKU_5_5Which model {ai} uses. An unknown model gives an error listing the valid choices.
AI_PERSONALITYAny textThe personality {ai} uses instead of your saved one.
ALLOW_COMPONENT_EXECUTIONS_FROM_EVERYONEtrue or falseLets anyone use the tag's buttons and select menus. By default only the person who ran the tag can.
DISPLAY_MEDIA_AS_NATIVEtrue or falseBy default, a reply that is only one file (or only one nsb.gg link) is shown like a media command's reply, with its size and who ran it. true sends it as a plain Discord attachment or link instead.
MEDIA_AV_FALLBACKSEARCH_YOUTUBE or search.youtube (or an alias like s.yt)When {transcribe} finds no audio or video, search YouTube with its argument instead.
MEDIA_IV_FALLBACKMEDIA_IMAGE_IMAGINE, SEARCH_GOOGLE_IMAGES or SEARCH_DUCK_DUCK_GO_IMAGES (or the function names, like imagine, and their aliases)When image functions like {image}, {iv}, {ocr} or {edit} find no image, generate one (as a temporary URL) or search for one using the argument instead.
ML_IMAGINE_DO_NOT_ERRORtrue or falsePassed to image generation as its "do not error" option.
ML_IMAGINE_MODELFLUX_KLEINWhich model image generation ({imagine}, {edit}, media scripts) uses.
{settings:MEDIA_IV_FALLBACK|search.google.images}{image:{args}}
→The last image in chat, or a Google Images result for the arguments if there is none.
{settings:ML_IMAGINE_MODEL|FLUX_KLEIN}{imagine:a cat in a tuxedo}
→An image generated with Flux Klein.

Limits

To keep things fast and fair, every run of a tag has limits. Going over one stops the tag with an error, except for the iteration limit (explained below). These limits are the same for everyone, premium or not, except how long the tag and its code may run. Verified tags from the tag directory always run with premium limits, whoever uses them. Each button or select menu click on a tag's message starts with fresh limits.

The iteration limit counts how many times the engine parses a piece of text: once for the tag itself and once for every argument that contains a function. When it runs out, the rest of the tag is output as plain text without being evaluated.

LimitDefaultWhat it covers
Run time40 secondsHow long the whole run can take, everything it calls included: 60 seconds in a premium server, 70 with Premium, 100 with Plus and 130 with Max.
Iterations450Times text is parsed per run. When it runs out the remaining text is output unevaluated.
Function calls10,000Functions called in one run, the tags it calls included.
Network requests15Functions that reach the internet: downloads, searches, attachments, code runs, looking up users and so on.
AI requests1{ai} calls.
Machine learning requests5Image generation and editing ({imagine}, {edit} and their URL versions).
Safety checks2{nsfwfilter} calls.
API actions1Functions that create something, like {api.create.reminder}.
Tag calls2Other tags run with {tag}.
Component runs2Times the tag can run again from button clicks, select menus or {componentsontimeout}.
Attachments10Files attached to the reply.
Embeds10Embeds in the reply.
Output text size10 MBAll the text the tag produces, or the channel's upload limit if that is smaller.
Pages1,000Pages added with {pagejson} or from code.
Variables100Variables set during one run.
Variable name length64 charactersLength of a variable's name.
Variable value length1 MBLonger values are cut off.
Storage key length128 charactersLength of a persistent storage key.
Storage value length16,384 charactersLength of a persistent storage value.
Storage keys per scope5Keys a scope (user, channel, server, global) may hold per tag, from set functions or code. Empty values do not count.
Blob size256 KBSize of each scope's blob, written from code.
Code run timeAbout 15 secondsHow long one code run can take before it is stopped: 20 seconds in a premium server, 30 with Premium and 45 with Plus.
Code output JSON check16,000 charactersPrinted output longer than this is never read as embed, component or page JSON, only as text.
Files loaded into code10Files from load lines in one code run.
Files from code10Files saved to the output folder in one run (the reply still holds 10 attachments in total).
Code network20 MbpsInternet speed inside the sandbox, at about 3 requests per second.
AI prompt length12,000 charactersLonger {ai} prompts are cut off.
Regex time25 msHow long {replace} can spend on a regular expression.
Math and replace time2 secondsTime {math} and {replace} can use in total in one run, the tags it calls included.
Loop size200Items {foreach} can loop over.

Output

When the tag finishes, all the text it produced is trimmed and sent as the message. Text is cut to 2,000 characters (or 4,000 when the message uses the newer component layouts). {newline} breaks survive this trimming.

Files added with {attach} (and files written by code) are sent as attachments, up to 10. Embeds from {embedjson} are sent along with the text, also up to 10. If the tag produces nothing at all, the bot replies with "Tag returned no content".

Buttons and select menus can be added with {componentjson}. Give a button or select menu a run field containing TagScript, and that code runs when it is clicked, keeping the same variables. The JSON itself is evaluated when the component is created, so wrap the run code in {ignore:...} if it should only run on click. Select menu choices are available as JSON in {get:__values}. A message can have up to 5 action rows or up to 25 loose buttons, but not both. Components stop working after one minute, and {componentsontimeout:...} can run TagScript when that happens.

Pages from {pagejson} turn the reply into a paginator you can flip through. When a tag has pages, the reply is made only of those pages, and other text and embeds are not shown. Pages cannot be added from a button click.

Before sending, the text, embeds and components are checked by a content filter, and a message with 150 or more line breaks is replaced with a spam notice. While running, a tag's text also cannot grow past the channel's upload size limit.

{embedjson:{"title": "Hello {user}", "color": 16711680}}
→A red embed titled "Hello cake".
{attach:https://cdn.nsb.gg/assets/samples/b1.png|bot.png}Look at this!
→The text "Look at this!" with the image attached as bot.png.
{componentjson:{"type": 2, "style": 1, "label": "Roll", "run": "You rolled {ignore:{range:1|6}}"}}
→A "Roll" button that rolls a new number every time it is clicked.

Errors

When a function fails (for example a download that does not work, a limit being reached, or setting a variable that starts with __), the whole tag stops and the bot replies with a "Command Error" message explaining what went wrong. Nothing else from the tag is sent.

Not every mistake is an error. Unknown function names, and functions given arguments they cannot use, are left in the output as plain text, which makes typos easy to spot.

To handle errors yourself, {iferror:a|b|c} tries each part in order and outputs the first one that does not fail (inside a later part, {get:error} is the message of the error before it), and {evalsilent:...} runs its contents and simply drops any error. To stop a tag on purpose, {exit:message} throws away everything produced so far and sends only the message, while {exitsilent:message} stops but keeps what was already produced. An exit inside {iferror} or {evalsilent} is not caught: it still stops the whole tag.

{iferror:{attach:{arg}}|That link didn't work!}
→Attaches the file, or says "That link didn't work!" if it can't be downloaded.
{iferror:{attach:{arg}}|Failed: {get:error}}
→Attaches the file, or says why it couldn't be downloaded.
{if:{argslen}|=|0|then:{exit:Please give me something to rate!}}Rating {args}...
→With no arguments: Please give me something to rate!

Arguments

Read what was passed to the tag.

{arg}

Outputs a single argument passed to the tag.

{arg[:index]}

Arguments are the text after the tag name, split on spaces. Words wrapped in quotes count as one argument, so "hello world" is a single argument (without the quotes).

indexoptional
Zero-based argument index, defaults to 0. Negative numbers count from the end (-1 is the last argument).
{arg}
→With .t mytag apple banana, outputs "apple".
{arg:1}
→With .t mytag apple banana, outputs "banana".
{arg:-1}
→The last argument.
  • If the index is out of range, nothing is output.
  • If the index is not a number, the function is left as-is in the output.

{args}

Outputs all of the tag's arguments, or a range of them.

{args[:start[|end]]}

With no argument it outputs the raw argument text exactly as typed. With a range, it takes a slice of the parsed argument list and joins it with single spaces.

startoptional
Zero-based index to start from, defaults to 0. Negative numbers count from the end.
endoptional
Index to stop before (exclusive), defaults to the number of arguments. Negative numbers count from the end.
{args}
→With .t mytag one two three, outputs "one two three".
{args:1}
→Everything except the first argument: "two three".
{args:0|-1}
→Everything except the last argument: "one two".
  • If start is not a number, the function is left as-is in the output.
  • When a range is used, quoted arguments lose their quotes and spacing is normalised to single spaces.

{argsafe}

Like {arg}, but escapes any | in the argument so it can be safely passed into other functions.

{argsafe[:index]}

Every unescaped | becomes \|, so a user typing a pipe will not accidentally split the arguments of the function you feed it into.

indexoptional
Zero-based argument index, defaults to 0. Negative numbers count from the end.
{set:word|{argsafe}}
→Stores the first argument in a variable, even if it contains |.
  • If the index is out of range, nothing is output.
  • If the index is not a number, the function is left as-is in the output.

{argslen}

Outputs how many arguments were passed to the tag.

{argslen}
{argslen}
→With .t mytag one "two three", outputs "2".
{if:{argslen}|=|0|then:Give me something!|else:You said {args}}
→Prompts the user when no arguments are given.
  • Quoted text counts as one argument.

{argssafe}

Like {args}, but escapes any | so the text can be safely passed into other functions.

{argssafe[:start[|end]]}
startoptional
Zero-based index to start from, defaults to 0. Negative numbers count from the end.
endoptional
Index to stop before (exclusive), defaults to the number of arguments. Negative numbers count from the end.
{set:input|{argssafe}}
→Stores all the arguments in a variable, even if they contain |.
{argssafe:1}
→Every argument after the first, with pipes escaped.
  • If start is not a number, the function is left as-is in the output.

Users

The person running the tag, or anyone else.

{avatar}

Outputs a user's avatar URL (1024px).

{avatar[:user]}
useroptional
A mention, ID, or name to look up. Defaults to whoever used the tag.
{avatar}
→Your avatar URL.
{avatar:439205512425504771}
→The avatar URL of that user.
{attach:{avatar:{arg}}}
→Attaches the avatar of the user named in the first argument.
  • Looking up a user counts against the network request limit; using it with no argument does not.
  • Outputs nothing if the user cannot be found.

{useravatar}

Outputs a user's avatar URL.

{useravatar:user?}

Gives the user's global (account) avatar at 1024px.

useroptional
Optional. A mention, a user ID, or a name to search the server members for. If left out, the person using the tag is used.
{useravatar}
→https://cdn.discordapp.com/avatars/.../....png?size=1024
{image:{useravatar:{args}}}
→Shows the avatar of the user given as an argument
  • Looking up another user counts as a network request. If nobody matches, nothing is output.

{userdiscriminator}

userdiscrimdiscrim

Outputs a user's discriminator (the old #0000 number).

{discrim:user?}
useroptional
Optional. A mention, a user ID, or a name to search the server members for. If left out, the person using the tag is used.
{discrim}
→0
{discrim:@SomeBot}
→1234
  • Users on Discord's newer username system have a discriminator of 0.
  • Looking up another user counts as a network request. If nobody matches, nothing is output.

{userid}

id

Outputs a user's ID.

{id:user?}
useroptional
Optional. A mention, a user ID, or a name to search the server members for. If left out, the person using the tag is used.
{id}
→300505364032389122
{id:{args}}
→The ID of the user given as an argument
  • Looking up another user counts as a network request. If nobody matches, nothing is output.

{usermention}

mention

Outputs a mention of a user.

{mention:user?}
useroptional
Optional. A mention, a user ID, or a name to search the server members for. If left out, the person using the tag is used.
Hey {mention}!
→Hey @you!
{mention:{randuserid}} got the cookie
→Mentions a random member
  • Looking up another user counts as a network request. If nobody matches, nothing is output.

{username}

nameuser

Outputs a user's username.

{user:user?}
useroptional
Optional. A mention, a user ID, or a name to search the server members for. If left out, the person using the tag is used.
Hello {user}!
→Hello cakedan!
{user:300505364032389122}
→The username of that user
  • This is the account username, not the server nickname. Use {nick} for that.
  • Looking up another user counts as a network request. If nobody matches, nothing is output.

{usernick}

nick

Outputs a user's display name, using their server nickname if they have one.

{nick:user?}
useroptional
Optional. A mention, a user ID, or a name to search the server members for. If left out, the person using the tag is used.
Welcome, {nick}!
→Welcome, Cake Lover!
  • Looking up another user counts as a network request. If nobody matches, nothing is output.

{userstatus}

Outputs a member's status: online, idle, dnd or offline.

{userstatus:user?}
useroptional
Optional. A mention, a user ID, or a name to search the server members for. If left out, the person using the tag is used.
{userstatus}
→online
{user:{args}} is {userstatus:{args}}
→cakedan is idle
  • Only works for members of the current server; outputs nothing in DMs or for users who aren't in the server.
  • Members with no known presence show as offline.
  • Looking up another user counts as a network request. If nobody matches, nothing is output.

{usertag}

Outputs a user's full tag (username with discriminator).

{usertag:user?}
useroptional
Optional. A mention, a user ID, or a name to search the server members for. If left out, the person using the tag is used.
{usertag}
→cakedan#0
  • Looking up another user counts as a network request. If nobody matches, nothing is output.

Servers & Channels

Information about where the tag is running.

{channel}

Outputs a channel's name.

{channel[:channel]}
channeloptional
A channel mention, ID, or name in this server. Defaults to the current channel.
{channel}
→Something like "general".
{channel:560595518129045504}
→The name of that channel.
  • In DMs (with no argument), outputs "Direct Message".
  • Only channels from the current server are found. Names are matched case-insensitively (starts-with first, then contains).
  • Outputs nothing if no channel is found.

{channelid}

Outputs a channel's ID.

{channelid[:channel]}
channeloptional
A channel mention, ID, or name in this server. Defaults to the current channel.
{channelid}
→The current channel's ID, e.g. "560595518129045504".
{channelid:general}
→The ID of the first channel matching "general".
  • Only channels from the current server are found. Names are matched case-insensitively.
  • Outputs nothing if no channel is found.

{channelmention}

Outputs a clickable mention of a channel.

{channelmention[:channel]}
channeloptional
A channel mention, ID, or name in this server. Defaults to the current channel.
{channelmention}
→A mention of the current channel, like <#560595518129045504>.
Please read {channelmention:rules}!
→Mentions the rules channel.
  • Only channels from the current server are found. Names are matched case-insensitively.
  • Outputs nothing if no channel is found.

{guild}

server

Outputs the server's name.

{guild}
Welcome to {guild}!
→Welcome to NotSoServer!
  • In DMs it outputs Direct Message.

{guildcount}

membercountservercount

Outputs how many members the server has.

{guildcount}
We have {membercount} members!
→We have 1234 members!
  • In DMs it outputs 2.

{guildid}

serveridsidgid

Outputs the server's ID.

{guildid}
{guildid}
→178313653177548800
  • In DMs it outputs 0.

{randchannelid}

Outputs the ID of a random channel in the server.

{randchannelid}
{randchannelid}
→560595518129045504
  • Picks from every channel in the server (including categories and voice channels).
  • In DMs it outputs the current channel's ID.

{randchannelmention}

Mentions a random channel in the server.

{randchannelmention}
Go check out {randchannelmention}!
→Go check out #general!
  • Picks from every channel in the server (including categories and voice channels).
  • In DMs it mentions the current channel.

Messages

The invoking message and the one it replies to.

{messagecontent}

Get the text of a message.

{messagecontent:message id?|channel?}

With no argument, outputs the content of the message that ran the tag (prefix commands only). With a message ID, outputs that message's content.

message idoptional
The ID of the message to read.
channeloptional
The channel the message is in (ID, mention or name). Defaults to the current channel.
{messagecontent}
→The full text of the message that ran the tag
{messagecontent:{messagelastid}}
→The text of the previous message in the channel
  • Looking up a channel counts as 1 network request, and so does fetching a message the bot has not cached.
  • You need View Channel and Read Message History in that channel, and the bot must be able to read its history, or the tag errors.
  • Outputs nothing if the message or channel can't be found, the message is in a different channel, or it is someone else's ephemeral message.

{messagelastid}

Get the ID of a recent message in a channel.

{messagelastid:position?|channel?}

Looks back through the channel's recent messages (skipping the one that ran the tag) and outputs the ID of the one at the given position. 0 is the most recent.

positionoptional
How far back to go, from 0 (newest) to 99, or random for a random one of the last 100. Defaults to 0; anything that isn't a number is treated as 0.
channeloptional
The channel to look in (ID, mention or name). Defaults to the current channel.
{messagelastid}
→1234567890123456789 (the previous message)
{messagelastid:2}
→The ID of the third most recent message
{messageuserid:{messagelastid:random}}
→The author of a random recent message
  • Errors if the position is 100 or more.
  • Looking up a channel counts as 1 network request, and so does fetching history when the bot has not cached enough messages.
  • You need View Channel and Read Message History in that channel, and the bot must be able to read its history, or the tag errors.
  • Other people's ephemeral messages are skipped.
  • Outputs nothing if there are no messages to pick from.

{messageuserid}

Get the ID of a message's author.

{messageuserid:message id?|channel?}

With no argument, outputs the ID of whoever sent the message that ran the tag (prefix commands only). With a message ID, outputs that message's author ID.

message idoptional
The ID of the message.
channeloptional
The channel the message is in (ID, mention or name). Defaults to the current channel.
{messageuserid}
→Your user ID
<@{messageuserid:{messagelastid}}>
→Mentions whoever sent the previous message
  • Looking up a channel counts as 1 network request, and so does fetching a message the bot has not cached.
  • You need View Channel and Read Message History in that channel, and the bot must be able to read its history, or the tag errors.
  • Outputs nothing if the message or channel can't be found, the message is in a different channel, or it is someone else's ephemeral message.

{randmessageid}

Get the ID of a random message from the last 100 in a channel.

{randmessageid:channel?}
channeloptional
The channel to look in (ID, mention or name). Defaults to the current channel.
{randmessageid}
→1234567890123456789
"{messagecontent:{randmessageid}}"
→Quotes a random recent message
  • The message that ran the tag and other people's ephemeral messages are skipped.
  • Looking up a channel counts as 1 network request, and so does fetching history when the bot has not cached 100 messages.
  • You need View Channel and Read Message History in that channel, and the bot must be able to read its history, or the tag errors.
  • Outputs nothing if there are no messages to pick from.

{replycontent}

Outputs the content of the message the invoking message is replying to.

{replycontent}
They said: {replycontent}
→They said: (the text of the replied-to message)
  • Only works when the tag is run from a normal message that replies to another message. Otherwise (including slash commands) nothing is output.

{replyuserid}

Outputs the user ID of the author of the message being replied to.

{replyuserid}
{replyuserid}
→300505364032389122
  • Only works when the tag is run from a normal message that replies to another message. Otherwise (including slash commands) nothing is output.

Variables & Storage

Remember values for this run, or keep them between runs.

{delete}

Deletes a variable set with {set}.

{delete:name}
name
The name of the variable to delete.
{set:count|5}{delete:count}{get:count|gone}
→gone
  • Outputs nothing.
  • Names starting with __ are private and cannot be deleted. Names longer than 64 characters cause an error.

{deletechannel}

Deletes a variable saved for this channel with {setchannel}.

{deletechannel:name}
name
The name of the stored variable to delete.
{deletechannel:highscore}
→Removes this channel's saved "highscore".
  • Outputs nothing, and failures are ignored silently.
  • Only works when running a saved tag. If the tag is an alias, the original tag's storage is used.
  • The variable name can be at most 128 characters, otherwise an error is thrown.

{deleteserver}

Deletes a variable saved for this server with {setserver}.

{deleteserver:name}
name
The name of the stored variable to delete.
{deleteserver:counter}
→Removes this server's saved "counter".
  • Outputs nothing, and failures are ignored silently.
  • In DMs the channel is used in place of the server.
  • Only works when running a saved tag. If the tag is an alias, the original tag's storage is used.
  • The variable name can be at most 128 characters, otherwise an error is thrown.

{deleteuser}

Deletes a variable saved for you with {setuser}.

{deleteuser:name}
name
The name of the stored variable to delete.
{deleteuser:coins}
→Removes your saved "coins".
  • Outputs nothing, and failures are ignored silently.
  • Always affects the person using the tag.
  • Only works when running a saved tag. If the tag is an alias, the original tag's storage is used.
  • The variable name can be at most 128 characters, otherwise an error is thrown.

{get}

Outputs the value of a variable set with {set}.

{get:name|default?}
name
The variable name. Functions inside it are evaluated, and surrounding spaces are trimmed.
defaultoptional
Optional. Output if the variable does not exist. Only evaluated when it is needed.
{set:food|cake}I like {get:food}
→I like cake
{get:missing|nothing here}
→nothing here
{get:__files}
→[{"filename":"image.png"}] (the files attached to the response so far)
  • Names longer than 64 characters cause an error.
  • The special name __files outputs a JSON array of the tag's files (filename and description).
  • If the variable does not exist and no default is given, nothing is output.

{getchannel}

Outputs a variable saved for this channel with {setchannel}.

{getchannel:name|default?}

Stored variables persist between uses of the tag. Channel variables are shared by everyone using the tag in this channel.

name
The stored variable name. Functions inside it are evaluated, and surrounding spaces are trimmed.
defaultoptional
Optional. Output if the variable does not exist. Only evaluated when it is needed.
Channel high score: {getchannel:highscore|0}
→Channel high score: 42
  • Only works when running a saved tag. If the tag is an alias, the original tag's storage is used. Otherwise nothing is output.
  • The variable name can be at most 128 characters, otherwise an error is thrown.

{getglobal}

Outputs a global variable saved with {setglobal}.

{getglobal:name|default?}

Global variables belong to the tag itself and are shared by everyone, in every server.

name
The stored variable name. Functions inside it are evaluated, and surrounding spaces are trimmed.
defaultoptional
Optional. Output if the variable does not exist. Only evaluated when it is needed.
This tag has been used {getglobal:uses|0} times
→This tag has been used 1337 times
  • Only works when running a saved tag. If the tag is an alias, the original tag's storage is used. Otherwise nothing is output.
  • The variable name can be at most 128 characters, otherwise an error is thrown.

{getserver}

Outputs a variable saved for this server with {setserver}.

{getserver:name|default?}

Server variables are shared by everyone using the tag in this server.

name
The stored variable name. Functions inside it are evaluated, and surrounding spaces are trimmed.
defaultoptional
Optional. Output if the variable does not exist. Only evaluated when it is needed.
Server counter: {getserver:counter|0}
→Server counter: 7
  • In DMs the channel is used in place of the server.
  • Only works when running a saved tag. If the tag is an alias, the original tag's storage is used. Otherwise nothing is output.
  • The variable name can be at most 128 characters, otherwise an error is thrown.

{getuser}

Outputs a variable saved for you with {setuser}.

{getuser:name|default?}

User variables are separate for each person using the tag, and follow them across servers.

name
The stored variable name. Functions inside it are evaluated, and surrounding spaces are trimmed.
defaultoptional
Optional. Output if the variable does not exist. Only evaluated when it is needed.
You have {getuser:coins|0} coins
→You have 150 coins
  • Always reads the variable of the person using the tag.
  • Only works when running a saved tag. If the tag is an alias, the original tag's storage is used. Otherwise nothing is output.
  • The variable name can be at most 128 characters, otherwise an error is thrown.

{set}

Set a variable for this run of the tag.

{set:name|value}

Stores a value under a name so you can read it back later with {get:name}. Variables only last for the current run; use {setserver}, {setuser}, {setchannel} or {setglobal} to keep values between runs.

name
The variable name. Cannot start with __ (those are reserved).
value
The value to store. Everything after the first | is used, so it can contain more | characters. Leading/trailing whitespace is trimmed.
{set:greeting|Hello there}{get:greeting}, {user}!
→Hello there, Cake!
{set:roll|{range:1|6}}You rolled {get:roll}
→You rolled 4
  • Names can be up to 64 characters and you can have up to 100 variables per run.
  • Values longer than 1 MiB are cut off.
  • Setting an existing name overwrites it.
  • The name and value can contain other functions; they are run before saving.
  • Without a | the function is left as plain text.

{setchannel}

Save a value for this tag, shared by everyone in the current channel.

{setchannel:name|value}

Keeps the value between runs. Read it back with {getchannel:name}.

name
The storage key.
value
The value to save.
{setchannel:lastuser|{user}}Saved!
→Saved! (and remembers you as the last user in this channel)
  • Keys can be up to 128 characters and values up to 16,384 characters, otherwise the tag errors.
  • Each tag can keep up to 5 keys per channel, server, user or global storage; saving a 6th key errors. An empty value deletes the key.
  • Storage belongs to the tag (aliases share the original tag's storage). Nothing is saved unless the code is running as a saved tag.
  • Both the key and the value can contain other functions; they are run before saving.
  • Without a | the function is left as plain text.

{setglobal}

Save a value for this tag, shared everywhere it is used.

{setglobal:name|value}

Keeps the value between runs, across every server, channel and user. Read it back with {getglobal:name}.

name
The storage key.
value
The value to save.
{setglobal:uses|{math:{getglobal:uses|0}+1}}Used {getglobal:uses} times
→Counts every use of the tag, everywhere
  • Keys can be up to 128 characters and values up to 16,384 characters, otherwise the tag errors.
  • Each tag can keep up to 5 keys per channel, server, user or global storage; saving a 6th key errors. An empty value deletes the key.
  • Storage belongs to the tag (aliases share the original tag's storage). Nothing is saved unless the code is running as a saved tag.
  • Both the key and the value can contain other functions; they are run before saving.
  • Without a | the function is left as plain text.

{setserver}

Save a value for this tag, shared by everyone in the current server.

{setserver:name|value}

Keeps the value between runs. Read it back with {getserver:name}. In DMs the channel is used instead of a server.

name
The storage key.
value
The value to save.
{setserver:motd|Be nice to each other}
→Saves a message of the day for this server
  • Keys can be up to 128 characters and values up to 16,384 characters, otherwise the tag errors.
  • Each tag can keep up to 5 keys per channel, server, user or global storage; saving a 6th key errors. An empty value deletes the key.
  • Storage belongs to the tag (aliases share the original tag's storage). Nothing is saved unless the code is running as a saved tag.
  • Both the key and the value can contain other functions; they are run before saving.
  • Without a | the function is left as plain text.

{setuser}

Save a value for this tag, private to the person running it.

{setuser:name|value}

Keeps the value between runs for the user running the tag, in any server. Read it back with {getuser:name}.

name
The storage key.
value
The value to save.
{setuser:color|blue}Your favourite colour is now {getuser:color}
→Remembers the colour just for you
  • Keys can be up to 128 characters and values up to 16,384 characters, otherwise the tag errors.
  • Each tag can keep up to 5 keys per channel, server, user or global storage; saving a 6th key errors. An empty value deletes the key.
  • Storage belongs to the tag (aliases share the original tag's storage). Nothing is saved unless the code is running as a saved tag.
  • Both the key and the value can contain other functions; they are run before saving.
  • Without a | the function is left as plain text.

{variables}

Outputs every variable in the current run as a JSON object.

{variables}

Useful for debugging. The output includes the variables you set with {set} as well as internal ones that start with __ (like __args and usage counters).

{set:fruit|apple}{variables}
→{"__args":[],...,"fruit":"apple"}

{variableschannel}

Outputs the tag's saved channel variables (for this channel) as a JSON object.

{variableschannel}
{variableschannel}
→{"counter":"5"}
  • Makes a request to fetch the saved variables of the current tag. If the tag is not being run as a saved tag (so there is no tag to look up), it outputs {}.
  • If the tag is an alias of another tag, the variables of the original tag are used.

{variablesglobal}

Outputs the tag's saved global variables as a JSON object.

{variablesglobal}
{variablesglobal}
→{"total_uses":"1234"}
  • Makes a request to fetch the saved variables of the current tag. If the tag is not being run as a saved tag (so there is no tag to look up), it outputs {}.
  • If the tag is an alias of another tag, the variables of the original tag are used.

{variablesserver}

Outputs the tag's saved server variables (for this server) as a JSON object.

{variablesserver}
{variablesserver}
→{"leader":"cakedan"}
  • Makes a request to fetch the saved variables of the current tag. If the tag is not being run as a saved tag (so there is no tag to look up), it outputs {}.
  • If the tag is an alias of another tag, the variables of the original tag are used.

{variablesuser}

Outputs the tag's saved user variables (for the person using the tag) as a JSON object.

{variablesuser}
{variablesuser}
→{"coins":"50"}
  • Makes a request to fetch the saved variables of the current tag. If the tag is not being run as a saved tag (so there is no tag to look up), it outputs {}.
  • If the tag is an alias of another tag, the variables of the original tag are used.

Logic & Control Flow

Conditions, loops, and stopping early.

{and}

Outputs the last value only if every value is non-empty.

{and:value1|value2|...}

Each value is evaluated in order. As soon as one comes out empty it stops and outputs nothing. If they are all non-empty, the last one is output.

value1|value2|...
Two or more values, split by |. Evaluated left to right, only as far as needed.
{and:{args}|You said {args}}
→You said hi (or nothing if no arguments were given)
{and:a||c}
→(nothing)
  • Without a | the function is left as plain text.

{error}

Stops the tag with a message as its error.

{error:message}

The tag stops and responds with the message as an error, the same way {js:console.error(message)} does, without starting any code. Good for bans, usage checks and wrong arguments.

message
The error to respond with.
{if:{args}|=||then:{error:You need to give me some text!}}You said {args}
→Error: You need to give me some text! (when no arguments are given)
{iferror:{error:nope}|Caught: {get:error}}
→Caught: nope
  • Unlike {exit}, it is caught by {iferror} and {evalsilent}.
  • Also stops the main tag when used inside a tag called with {tag}.

{exit}

Stops the tag immediately and replaces the whole output with a message.

{exit:message?}

Everything produced so far (text, embeds, files, pages and components) is thrown away and the response becomes the given message.

messageoptional
Optional. The text to respond with. Defaults to Tag Exited.
{if:{args}|=||then:{exit:Please give me some text!}}You said {args}
→Please give me some text! (when no arguments are given)
Hello{exit}
→Tag Exited
  • Also stops the main tag when used inside a tag called with {tag}.
  • It is not caught by {iferror} or {evalsilent}, it still stops the whole tag.

{exitsilent}

Stops the tag immediately, keeping everything output so far.

{exitsilent:message?}
messageoptional
Optional. Text added to the end of the output before stopping.
Hello{exitsilent: world} this is never shown
→Hello world
  • Also stops the main tag when used inside a tag called with {tag}.
  • It is not caught by {iferror} or {evalsilent}, it still stops the whole tag.

{foreach}

Runs code once for every item in a list, or a set number of times.

{foreach:list|code}

The first value is evaluated, then:

  • a whole number runs the code that many times;
  • a JSON array runs it once per item;
  • a JSON object runs it once per key;
  • a JSON string is split into words (like command arguments, quotes keep words together) and runs once per word.

Inside the code, {get:idx} is the current index (or object key) and {get:valuex} is the current item (objects and arrays come out as JSON). The output of every run is joined together with nothing in between.

list
A number, or a JSON array/object/string to loop over.
code
The tagscript to run for each item. Everything after the first | is part of the code.
{foreach:["a","b","c"]|{get:idx}={get:valuex} }
→0=a 1=b 2=c
{foreach:3|Hi! }
→Hi! Hi! Hi!
{foreach:{"x":1,"y":2}|{get:idx}:{get:valuex}{newline}}
→x:1 and y:2 on separate lines
  • At most 200 iterations, more causes an error.
  • If the list is invalid JSON, empty, or anything else, nothing is output.
  • Without a | the function is left as plain text.

{if}

Compares two values and runs then: or else: depending on the result.

{if:value1|comparison|value2|then:code|else:code}

Comparisons: = equal, != not equal, > >= < <= numeric comparisons (decimals work), ~ which compares numbers by value or text case-insensitively, and ? which checks if the first value matches the regex in the second value (case-insensitive).

After the two values, give up to three branches starting with then:, else: or finally:, in any order. Only the branch that matches is evaluated, then finally: (if given) is evaluated and added after it.

value1
The first value to compare.
comparison
One of =, !=, >, >=, <, <=, ~, ?. Write it with no spaces around it.
value2
The second value to compare.
then:codeoptional
Output when the comparison is true.
else:codeoptional
Output when the comparison is false.
finally:codeoptional
Always evaluated and output after then/else (without the finally: prefix).
{if:{args}|=|hello|then:Hi there!|else:You did not say hello.}
→Hi there! (when the argument is "hello")
{if:{range:1|10}|>|5|then:High|else:Low}
→High or Low
{if:YES|~|yes|then:match}
→match
{if:{args}|?|^(hi\|hello)$|then:Hey!|else:...}
→Hey! (when the argument is "hi" or "Hello")
{if:1|=|2|then:same|else:different|finally:!}
→different!
  • >, >=, < and <= are false if either value is not a number.
  • ? matches anywhere in the text unless the regex uses ^ and $. Escape | as \| inside the regex. An invalid regex, or one that takes too long, causes an error.
  • At least one branch is required, and each branch can only appear once (a duplicate causes an error).
  • Branches must start exactly with then:, else: or finally: (no leading spaces), and the comparison must be a valid operator, otherwise the function is left as plain text.

{iferror}

Outputs the first value that does not throw an error.

{iferror:code1|code2|...}

Tries each value in order. If evaluating one errors, its output is dropped and the next one is tried, with {get:error} set to that error's message. If they all error, nothing is output.

code1|code2|...
Values to try, split by |.
{iferror:{getfilename:3}|No third file!}
→No third file! (when there are fewer than 3 files)
{iferror:{attach:{arg}}|Couldn't attach it: {get:error}}
→The download error, when the link doesn't work
  • With a single value (no |), it is evaluated and output, or nothing is output if it errors.
  • An {exit} or {exitsilent} inside is not caught, it still stops the whole tag.
  • error only exists inside the {iferror}, afterwards it goes back to what it was before.

{includes}

Outputs true if the text matches any of the given values, otherwise false.

{includes:text|value1|value2|...}

The first value is compared against each of the others in order (exact, case-sensitive match).

text
The text to look for. Functions inside it are evaluated, the same way as the values.
value1|value2|...
The values to compare against. These are evaluated one by one until a match is found.
{includes:cake|pie|cake|cookie}
→true
{includes:{lower:{args}}|yes|y}
→true when the arguments are "yes" or "Y"
{includes:Cake|cake}
→false
  • Without a | the function is left as plain text.

{or}

Outputs the first value that is not empty.

{or:value1|value2|...}

Each value is evaluated in order and the first non-empty one is output. Later values are not evaluated. If they are all empty, nothing is output.

value1|value2|...
Values to try, split by |.
Hello {or:{args}|stranger}!
→Hello stranger! (when no arguments are given)
{or:{get:nick}|{get:name}|Unknown}
→The first of those variables that is set
  • With a single value (no |), it is evaluated and output.

Math

Arithmetic and number helpers.

{abs}

Absolute value of a number.

{abs:number}
number
A number, decimals work.
{abs:-42}
→42
{abs:-5.7}
→5.7
  • Left as plain text if the argument is not a number.

{cos}

Cosine of an angle in radians.

{cos:radians}
radians
The angle in radians, decimals work.
{cos:0}
→1
{cos:{pi}}
→-1
  • Left as plain text if the argument is not a number.

{e}

Euler's number.

{e}
{e}
→2.718281828459045

{math}

Evaluate a math expression.

{math:expression}

Uses a math.js parser with high-precision (BigNumber) numbers, so things like 0.1+0.2 give 0.3. Supports + - * / % ^, parentheses, ** (treated as ^), comparisons, functions like sqrt, round, floor, ceil, abs, min, max, log, pow, sin/cos/tan, constants like pi and e, unit conversions like 5 inch to cm, and base conversions with base(number, base) and frombase("digits", base) for bases 2 to 36 (0-9 then a-z).

Numbers with thousands separators such as 1,000,000 are understood. Results that repeat forever are rounded to 2 decimal places, and trailing zeros are removed.

expression
The expression to evaluate. Whitespace around it is trimmed.
{math:5+5}
→10
{math:2**10 / 4}
→256
{math:10/3}
→3.33
{math:base(1295, 36)}
→zz
{math:frombase("zz", 36)}
→1295
  • Each expression has a 750ms time limit; slow expressions error with a timeout.
  • Invalid expressions make the tag error with the math error message.
  • Unit conversions output only the number, without the unit name.
  • Within one run, variables assigned in an expression (like x = 5) can be reused by later {math} calls, as long as those calls use the variable name.

{max}

The largest of a list of whole numbers.

{max:number|number|...}
numbers
One or more numbers separated by |. Decimal parts are dropped, and very large numbers are handled exactly.
{max:3|17|8}
→17
{max:2.9|2.1}
→2
  • Left as plain text if the argument is empty or any value is not a number.

{min}

The smallest of a list of whole numbers.

{min:number|number|...}
numbers
One or more numbers separated by |. Decimal parts are dropped, and very large numbers are handled exactly.
{min:3|17|8}
→3
{min:-4|10}
→-4
  • Left as plain text if the argument is empty or any value is not a number.

{pi}

The number pi.

{pi}
{pi}
→3.141592653589793

{sin}

Sine of an angle in radians.

{sin:radians}
radians
The angle in radians, decimals work.
{sin:0}
→0
  • Left as plain text if the argument is not a number.

{tan}

Tangent of an angle in radians.

{tan:radians}
radians
The angle in radians, decimals work.
{tan:0}
→0
  • Left as plain text if the argument is not a number.

{type}

Converts text into a number, with an optional fallback.

{type:type|value|default?}

The supported types are number (a whole number, read with parseInt) and float (a decimal number, read with parseFloat). Reading stops at the first character that isn't part of a number, so 12abc becomes 12.

type
number or float (case insensitive).
value
The text to convert.
defaultoptional
Used if the value isn't a number.
{type:number|42.9}
→42
{type:float|3.14abc}
→3.14
{type:number|hello|0}
→0
  • If the value isn't a number and there is no default, nothing is output.
  • An unknown type, a non-numeric default, or a missing | makes the function fail.

Text

Change, search, and measure text.

{bracketleft}

Outputs a literal {.

{bracketleft:amount?}
amountoptional
Optional. How many times to insert it. Must be a whole number above 0.
{bracketleft}
→{
{bracketleft:3}
→{{{
  • If the amount is not a number, the function is left as plain text.
  • An amount of 0 or less (or an absurdly large one) causes an error.

{bracketright}

Outputs a literal }.

{bracketright:amount?}
amountoptional
Optional. How many times to insert it. Must be a whole number above 0.
{bracketright}
→}
{bracketleft}user{bracketright}
→{user}
  • If the amount is not a number, the function is left as plain text.
  • An amount of 0 or less (or an absurdly large one) causes an error.

{indexof}

Outputs the position of the first match of some text inside other text.

{indexof:search|text}

Positions start at 0. Outputs -1 if the text is not found. The search is case-sensitive.

search
The text to look for.
text
The text to search in. Everything after the first | is part of it.
{indexof:,|the cat jumped, over a dog}
→14
{indexof:z|hello}
→-1
  • Plain values (without functions in them) are trimmed of surrounding spaces.
  • Without a |, the function is left in the output as plain text.

{len}

length

Outputs the number of characters in the text.

{len:text}
text
The text to measure.
{len:hello}
→5
{length:{args}}
→How long the arguments are
  • Surrounding spaces are trimmed before measuring. Some emoji count as 2 characters.

{lower}

Converts text to lowercase.

{lower:text}
text
The text to convert.
{lower:HELLO World}
→hello world

{newline}

Outputs a line break.

{newline:amount?}

Useful where a normal line break would get trimmed away, like at the start or end of a function argument.

amountoptional
Optional. How many times to insert it. Must be a whole number above 0.
Line one{newline}Line two
→Line one Line two
Top{newline:3}Bottom
→Top, three line breaks, then Bottom
  • If the amount is not a number, the function is left as plain text.
  • An amount of 0 or less (or an absurdly large one) causes an error.
  • It is inserted as an internal placeholder character that becomes a line break once the tag finishes, so it survives trimming in between. Inside the JSON strings of {embedjson}, {pagejson} and {componentjson} it becomes a line break too.

{nsfwfilter}

Outputs the text only if a safety scan does not flag it as unsafe.

{nsfwfilter:text}

The text is sent to a moderation scan. If it passes, the text (cut to 2000 characters) is output; if it is flagged, nothing is output.

text
The text to check.
{nsfwfilter:{args}}
→The arguments, or nothing if they were flagged
  • Counts as one network request and one safety request (2 safety requests are allowed per run by default), even with empty text.
  • The scan is stricter outside of NSFW channels.
  • If the safety service is unavailable, the text is treated as unsafe and nothing is output.
  • The text is cut to 2000 characters.

{oneof}

Finds the choice that best matches a value.

{oneof:value|choice1|choice2|...}

First looks for a choice that contains the value (case-insensitive) and outputs the first one found. If none do, a fuzzy search is used to find the closest choice, which is handy for typos or partial input.

value
The text to match.
choices
The possible choices, separated by |.
{oneof:ban|apple|banana|cherry}
→banana
{oneof:chery|apple|banana|cherry}
→cherry
{oneof:{args}|rock|paper|scissors}
→The choice closest to what the user typed
  • Outputs nothing if nothing matches, or if the value or choices are missing.
  • With no argument at all, the function is left in the output as plain text.

{repeat}

Repeats text a number of times.

{repeat:amount|text}
amount
How many times to repeat the text (a whole number).
text
The text to repeat. Everything after the first | is part of it, and it is trimmed.
{repeat:3|ha}
→hahaha
{repeat:5|⭐}
→⭐⭐⭐⭐⭐
  • If the result would make the output larger than the max upload size, the tag errors.
  • Without a |, or if the amount is not a number or is negative, the function is left in the output as plain text.

{replace}

replaceregex

Replaces every match of a regular expression in some text.

{replace:pattern|replacement|text}

The first part is a JavaScript regular expression, which always runs with the g (replace all) and i (case-insensitive) flags; other flags cannot be set. A plain word works too, since it is just a regex with no special characters.

By default the order is pattern, replacement, then the text. You can also label the parts with with: and in: to write them in either order. The replacement can use $1, $2, ... to insert captured groups, and $& for the whole match.

pattern
The regular expression to look for. Escape any | in it as \|.
replacement
What to replace each match with. Can be prefixed with with:.
text
The text to search in. Can be prefixed with in:. Everything after the second | is part of it.
{replace:cat|dog|The Cat sat with another cat}
→The dog sat with another dog
{replace:(cake\|josh)|tom|cake went with josh to the store}
→tom went with tom to the store
{replace:"|in:"help"|with:'}
→'help'
  • Regex special characters such as ., ?, (, [ and * need a backslash if you want to match them literally.
  • An invalid regex, or one that takes longer than 25ms to run, is an error.
  • With fewer than three parts, the function is left in the output as plain text.

{reverse}

Reverses text.

{reverse:text}
text
The text to reverse.
{reverse:hello}
→olleh
  • Single emoji stay whole, but emoji made of several parts (flags, skin tones, families) can break when reversed.

{splitterargument}

Outputs a literal | (the argument splitter).

{splitterargument:amount?}
amountoptional
Optional. How many times to insert it. Must be a whole number above 0.
a{splitterargument}b
→a|b
{splitterargument:2}
→||
  • If the amount is not a number, the function is left as plain text.
  • An amount of 0 or less (or an absurdly large one) causes an error.

{splitterfunction}

Outputs a literal : (the function splitter).

{splitterfunction:amount?}
amountoptional
Optional. How many times to insert it. Must be a whole number above 0.
12{splitterfunction}30
→12:30
  • If the amount is not a number, the function is left as plain text.
  • An amount of 0 or less (or an absurdly large one) causes an error.

{substring}

Outputs part of some text, by position.

{substring:text|start|end?}

Positions start at 0. The output starts at start and ends just before end (or at the end of the text). Negative positions count as 0, and if start is bigger than end the two are swapped.

text
The text to cut. It cannot contain an unescaped |.
start
The position to start at.
endoptional
The position to stop before. Defaults to the end of the text.
{substring:hello world|6}
→world
{substring:hello world|0|5}
→hello
{substring:{args}|0|1}
→The first character of the arguments
  • Without a |, with empty text or start, or if start/end are not numbers, the function is left in the output as plain text.

{translate}

Translates text with Google Translate.

{translate:text|language?}

If there is more than one part, the last part is checked as a language name or code (e.g. russian, ja, or random). If it is not a language, it is treated as part of the text.

Without a language, the text is translated into your language: your NotSoBot language setting, then your Discord language (for slash commands), then the server's language setting, then the server's preferred language, then English.

text
The text to translate. The source language is detected automatically.
languageoptional
The language to translate into. Matching is fuzzy, so close spellings work.
{translate:hello|spanish}
→Hola
{translate:bonjour}
→Hello (if your language is English)
{translate:good morning|random}
→Good morning in a random language
  • Counts as one network request, even with empty text.
  • If the translation fails, nothing is output.
  • Because the last part is fuzzy-matched against language names, text containing a | can have its last piece mistaken for a language.

{upper}

Converts text to UPPERCASE.

{upper:text}
text
The text to convert.
{upper:hello world}
→HELLO WORLD
{upper:{user}}
→Your username in uppercase

{url}

urlencode

URL-encodes text so it can be safely put inside a link.

{url:text}

Uses standard URI component encoding, so spaces become %20, & becomes %26, and so on.

text
The text to encode.
{url:cats & dogs}
→cats%20%26%20dogs
https://www.google.com/search?q={url:{args}}
→A Google search link for whatever was passed into the tag

Discord Markdown

Wrap text in Discord formatting.

{code}

markupcodeblock

Puts text in a code block.

{code:text}

Wraps the text in triple backticks, on their own lines. Any triple backticks in the text are broken up so they cannot end the block early.

text
The text to put in the code block.
{code:console.log("hi");}
→`` console.log("hi"); ``
  • No language can be set for syntax highlighting.
  • Unlike most markup functions, mentions are not escaped. The text is cut to roughly 2000 bytes.

{markupbold}

Makes text **bold**.

{markupbold:text}

Wraps the text in **. Any ** already in the text is escaped.

text
The text to format.
{markupbold:hello}
→**hello**
  • @ signs are escaped with an invisible character so mentions, @everyone and @here will not ping.
  • The text is cut to roughly 2000 bytes.

{markupcodestring}

Formats text as inline code.

{markupcodestring:text}

Wraps the text in single backticks. If the text contains a backtick, double backticks are used instead.

text
The text to format.
{markupcodestring:npm install}
→npm install
  • @ signs are escaped with an invisible character so mentions, @everyone and @here will not ping.
  • The text is cut to roughly 2000 bytes.

{markupescape}

Escapes Discord markdown so the text shows exactly as typed.

{markupescape:text}

Escapes backslashes, *, _, backticks, ||, ~~, __, > and leading #/-#, and breaks up masked links. Useful for showing user input without it being formatted.

text
The text to escape.
{markupescape:**not bold**}
→\*\*not bold\*\*
  • @ signs are escaped with an invisible character so mentions, @everyone and @here will not ping.
  • The text is cut to roughly 2000 bytes.

{markupheaderbig}

Makes text a big header (# text).

{markupheaderbig:text}
text
The header text.
{markupheaderbig:Welcome}
→# Welcome
  • New lines in the text are replaced with spaces, so the formatting covers a single line.
  • @ signs are escaped with an invisible character so mentions, @everyone and @here will not ping.
  • Headers only render at the start of a line, so put a new line before it if needed.

{markupheadermedium}

Makes text a medium header (## text).

{markupheadermedium:text}
text
The header text.
{markupheadermedium:Rules}
→## Rules
  • New lines in the text are replaced with spaces, so the formatting covers a single line.
  • @ signs are escaped with an invisible character so mentions, @everyone and @here will not ping.
  • Headers only render at the start of a line, so put a new line before it if needed.

{markupheadersmall}

Makes text a small header (### text).

{markupheadersmall:text}
text
The header text.
{markupheadersmall:Details}
→### Details
  • New lines in the text are replaced with spaces, so the formatting covers a single line.
  • @ signs are escaped with an invisible character so mentions, @everyone and @here will not ping.
  • Headers only render at the start of a line, so put a new line before it if needed.

{markupitalics}

Makes text _italic_.

{markupitalics:text}

Wraps the text in _. Any _ or * in the text is escaped.

text
The text to format.
{markupitalics:hello}
→_hello_
  • @ signs are escaped with an invisible character so mentions, @everyone and @here will not ping.
  • The text is cut to roughly 2000 bytes.

{markuplistdotted}

Turns |-separated items into a bulleted list.

{markuplistdotted:item1|item2|...}
items
The list items, separated by |.
{markuplistdotted:apples|bananas|cherries}
→- apples - bananas - cherries
  • Each item is kept on one line (new lines become spaces), and - or * inside an item is escaped.
  • @ signs are escaped with an invisible character so mentions, @everyone and @here will not ping.

{markuplistnumbered}

Turns |-separated items into a numbered list.

{markuplistnumbered:item1|item2|...}
items
The list items, separated by |.
{markuplistnumbered:first|second|third}
→1. first 2. second 3. third
  • Numbering starts at 1.
  • Each item is kept on one line (new lines become spaces), and - or * inside an item is escaped.
  • @ signs are escaped with an invisible character so mentions, @everyone and @here will not ping.

{markupquote}

Makes text a block quote (> text).

{markupquote:text}
text
The text to quote.
{markupquote:{replycontent}}
→> (the replied-to message)
  • New lines in the text are replaced with spaces, so the formatting covers a single line.
  • Any > in the text is escaped.
  • @ signs are escaped with an invisible character so mentions, @everyone and @here will not ping.

{markupspoiler}

Hides text behind a ||spoiler||.

{markupspoiler:text}
text
The text to hide.
{markupspoiler:the butler did it}
→||the butler did it||
  • Any || in the text is escaped.
  • @ signs are escaped with an invisible character so mentions, @everyone and @here will not ping.
  • The text is cut to roughly 2000 bytes.

{markupstrike}

Crosses text out with ~~strikethrough~~.

{markupstrike:text}
text
The text to cross out.
{markupstrike:old price}
→~~old price~~
  • Any ~~ in the text is escaped.
  • @ signs are escaped with an invisible character so mentions, @everyone and @here will not ping.
  • The text is cut to roughly 2000 bytes.

{markupsubtext}

Makes text small, grey subtext (-# text).

{markupsubtext:text}
text
The text to format.
{markupsubtext:requested by {user}}
→-# requested by cake
  • New lines in the text are replaced with spaces, so the formatting covers a single line.
  • @ signs are escaped with an invisible character so mentions, @everyone and @here will not ping.
  • Subtext only renders at the start of a line.

{markuptime}

Outputs a Discord timestamp (<t:...>) that shows in each viewer's own timezone.

{markuptime:time?|style?}

The time can be a number of milliseconds since 1970 or a date string such as 2025-01-01T12:00:00Z. With no time, the current time is used.

The last part can be a style: BOTH_LONG (F), BOTH_SHORT (f), DATE_LONG (D), DATE_SHORT (d), RELATIVE (R), TIME_LONG (T) or TIME_SHORT (t). Style names are case-insensitive, the single letters are Discord's own and are case-sensitive. Without a style, Discord's default format is used. A style on its own (like {markuptime:RELATIVE}) uses the current time.

timeoptional
Milliseconds since 1970, or a date string. Defaults to now.
styleoptional
How Discord shows the time, see above.
{markuptime}
→<t:1760313600> (the current time)
{markuptime:1700000000000}
→<t:1700000000>
{markuptime:1700000000000|RELATIVE}
→<t:1700000000:R> (shows as something like "2 years ago")
{markuptime:2025-01-01T12:00:00Z|D}
→<t:1735732800:D>
  • Numbers are read as milliseconds, not seconds. A Unix timestamp in seconds will show as a date in January 1970.
  • If the time cannot be read as a date, the function is left in the output as plain text.

{markupunderline}

Underlines text (__text__).

{markupunderline:text}
text
The text to underline.
{markupunderline:important}
→__important__
  • Any __ in the text is escaped.
  • @ signs are escaped with an invisible character so mentions, @everyone and @here will not ping.
  • The text is cut to roughly 2000 bytes.

{markupurl}

Makes a masked link: clickable text that goes to a URL.

{markupurl:text|url|tooltip?}
text
The text to show.
url
Where the link goes.
tooltipoptional
Text shown when hovering over the link. Everything after the second | is part of it.
{markupurl:NotSoBot|https://notsobot.com}
→[NotSoBot](https://notsobot.com)
{markupurl:Docs|https://notsobot.com|Read the docs}
→[Docs](https://notsobot.com 'Read the docs')
  • Any ) in the URL is encoded as %29 so it does not break the link.
  • The URL is required; leaving it out is an error.

Randomness

Random picks, numbers, and IDs.

{choose}

Picks one of the given choices at random.

{choose:choice1|choice2|...}

Only the picked choice is evaluated, so functions inside the other choices never run. This makes it safe to put things like {set} or network calls in the choices.

choices
The options to pick from, separated by |. With no |, the single value is output.
{choose:heads|tails}
→heads or tails
{choose:You win!|You lose, {user}.}
→One of the two messages
  • With no argument, the function is left in the output as plain text.

{randchannel}

Outputs the name of a random channel in the server.

{randchannel}
Go hang out in #{randchannel}!
→Something like "Go hang out in #memes!".
  • Picks from every channel the bot knows about in the server, which can include categories and voice channels.
  • In DMs, outputs "Direct Message".

{randomonline}

randonline

Outputs the display name of a random member that has a presence (online, idle or dnd).

{randonline}
{randonline} has been chosen!
→Some Online Member has been chosen!
  • Only picks from members NotSoBot has cached with a presence.
  • In DMs it picks between the person using the tag and NotSoBot itself.

{randomonlineid}

randonlineid

Outputs the ID of a random member that has a presence (online, idle or dnd).

{randonlineid}
{randonlineid}
→123456789012345678
  • Only picks from members NotSoBot has cached with a presence.
  • In DMs it picks between the person using the tag and NotSoBot itself.

{randomonlinetag}

randonlinetag

Outputs the full user tag of a random member that has a presence (online, idle or dnd).

{randonlinetag}
{randonlinetag}
→someone#0
  • Only picks from members NotSoBot has cached with a presence.
  • In DMs it picks between the person using the tag and NotSoBot itself.

{randomuser}

randuser

Outputs the display name of a random server member.

{randuser}
{randuser} stole the cookie!
→Some Member stole the cookie!
  • If the server's member list isn't fully loaded yet, NotSoBot requests it first, which can take a moment on big servers.
  • In DMs it picks between the person using the tag and NotSoBot itself.

{randomuserid}

randuserid

Outputs the ID of a random server member.

{randuserid}
{randuserid}
→123456789012345678
{mention:{randuserid}}
→Mentions a random member
  • If the server's member list isn't fully loaded yet, NotSoBot requests it first, which can take a moment on big servers.
  • In DMs it picks between the person using the tag and NotSoBot itself.

{randomusertag}

randusertag

Outputs the full user tag of a random server member.

{randusertag}
{randusertag}
→someone#0
  • If the server's member list isn't fully loaded yet, NotSoBot requests it first, which can take a moment on big servers.
  • In DMs it picks between the person using the tag and NotSoBot itself.

{range}

randomrnd

Outputs a random whole number in a range, including both ends.

{range:max} or {range:min|max}

With one number, picks between 0 and that number. With two, picks between them; the order does not matter. Very large numbers are supported.

minoptional
The lowest number. Defaults to 0.
max
The highest number.
{range:10}
→A number from 0 to 10, e.g. 7
{random:1|6}
→A dice roll, e.g. 4
{rnd:-5|5}
→A number from -5 to 5
  • Decimals are cut off ({range:1.9|5.5} is the same as {range:1|5}).
  • If either value is not a number, or there is no argument, the function is left in the output as plain text.

{uuid}

Generates a random UUID.

{uuid:version?}
versionoptional
4 (the default) for a fully random UUID, or 7 for a time-ordered one.
{uuid}
→3b241101-e2bb-4255-8caf-4136c566a962
{uuid:7}
→A UUID v7, e.g. 0192a3e4-5b6c-7d8e-9f01-23456789abcd
  • Any other version is left in the output as plain text.

Media

Find, attach, and edit images, audio, and video.

{api.utilities.exif}

Reads an image, audio or video's metadata and outputs it as JSON.

{api.utilities.exif[:url]}

Outputs an object like {"metadata": {...}, "channels": {...}, "exif": [...]}. metadata has the mimetype, width, height, size (bytes), duration and frames. channels has the image, video and audio streams with their codecs, bitrates, frame rates and sample rates (an animated image's frame delays, loop and gif comment too). exif is the photo's EXIF fields, each with a name, value and description. With no argument, the last media in the chat is used.

urloptional
A media url, user, or emoji. Defaults to the last media in the chat.
{traversejson:metadata.mimetype|{api.utilities.exif}}
→The type of the last media, like image/png.
{traversejson:channels.video[0].frames_per_second|{api.utilities.exif}}
→The frame rate of the last video.
  • Counts against the network request limit twice, once to find the media and once to read it. Reading the same media again in one run reuses the cached result.
  • Durations and frame delays are in milliseconds.
  • Throws an error if no media can be found.

{attachment}

attachfile

Downloads a URL and attaches it as a file to the tag's message.

{attach:url[|filename[|description]]}

Besides normal URLs, you can pass a user mention or ID (attaches their avatar) or an emoji (custom or unicode). URLs without http(s):// get https:// added.

Attached files can later be referenced in {ai} and code functions as FILE_1, FILE_2, etc.

url
The URL, user, or emoji to download.
filenameoptional
Name to give the file. Defaults to the name from the download.
descriptionoptional
Alt text for the file. Everything after the second | is used.
{attach:https://cdn.nsb.gg/assets/samples/b1.png}
→Sends b1.png along with the message.
{attach:{avatar}|me.png|My avatar}
→Attaches your avatar as me.png with alt text.
  • Counts against the network request limit. Attaching the same URL again in one run reuses the download without counting again.
  • Up to 10 attachments per run by default; going over throws an error. If attachments are disabled for this run, the function is left as-is.
  • Each file must fit within the upload size limit of the server/channel, or an error is thrown.
  • Downloads use SafeSearch-style filtering unless the channel allows NSFW content.
  • An invalid URL throws an error.

{attachmentspoiler}

attachspoilerfilespoiler

Same as {attach}, but the file is marked as a spoiler.

{attachspoiler:url[|filename[|description]]}
url
The URL, user, or emoji to download.
filenameoptional
Name to give the file. Defaults to the name from the download.
descriptionoptional
Alt text for the file.
{attachspoiler:https://cdn.nsb.gg/assets/samples/face.png}
→Sends the image hidden behind a spoiler.
  • Shares all limits and behaviour with {attach}.

{attachmenttext}

attachtextfiletext

Attaches the given text as a .txt file.

{attachtext:text}

The first file is named content.txt; if other files are already attached, it becomes content.2.txt, content.3.txt, etc. The whole argument is used as the file content, including any |.

text
The content of the text file.
{attachtext:{args}}
→Sends the arguments as content.txt.
  • Does not use a network request.
  • Counts toward the attachment limit (10 per run by default). If attachments are disabled for this run, the function is left as-is.
  • The text must fit within the upload size limit, or an error is thrown.

{attachmentvoice}

attachvoicefilevoice

Downloads audio or video from a URL and attaches it as a Discord voice message.

{attachvoice:url[|filename]}

The audio is extracted and converted to OGG with a waveform, so it shows up like a voice message.

url
URL of the audio or video to use.
filenameoptional
Name to give the file. Everything after the first | is used.
{attachvoice:https://cdn.nsb.gg/assets/samples/voice.mp3}
→Sends voice.mp3 as a voice message.
  • Always counts against the network request limit (not cached).
  • Counts toward the attachment limit (10 per run by default). If attachments are disabled for this run, the function is left as-is.
  • The result must fit within the upload size limit, or an error is thrown.

{audio}

Get the URL of an audio file.

{audio:query?}

Works like {media} but only matches audio.

With no argument, the bot looks for the most recent matching media in this order: an attachment on a slash command, the message that ran the tag (attachments, embeds, stickers), the message it replies to, then the channel's last 25 messages (the ones the bot has cached first, then fetched if the bot can read message history).

With an argument, attachments on the message that ran the tag and the message it replies to still come first. After that the argument is read as: ^ (the last media, same as no argument), ^2 to ^99 (the media before that, counting back with the attachments and reply as the newest), a URL or a Discord message link (it takes the media from that message), a user mention, ID, @name or name#0000 (that user's avatar), a custom emoji (its image), a unicode emoji (its Twemoji image), or a member name search (their avatar).

queryoptional
A URL, message link or ^. Leave empty to use the last audio in the channel.
{audio}
→https://cdn.discordapp.com/attachments/.../song.mp3
  • Counts as 1 network request, even if nothing is found.
  • Outputs nothing if no matching media is found.

{av}

Get the URL of an audio or video file.

{av:query?}

Works like {media} but skips images.

With no argument, the bot looks for the most recent matching media in this order: an attachment on a slash command, the message that ran the tag (attachments, embeds, stickers), the message it replies to, then the channel's last 25 messages (the ones the bot has cached first, then fetched if the bot can read message history).

With an argument, attachments on the message that ran the tag and the message it replies to still come first. After that the argument is read as: ^ (the last media, same as no argument), ^2 to ^99 (the media before that, counting back with the attachments and reply as the newest), a URL or a Discord message link (it takes the media from that message), a user mention, ID, @name or name#0000 (that user's avatar), a custom emoji (its image), a unicode emoji (its Twemoji image), or a member name search (their avatar).

queryoptional
A URL, message link or ^. Leave empty to use the last audio/video in the channel.
{av}
→https://cdn.discordapp.com/attachments/.../clip.mp4
  • Counts as 1 network request, even if nothing is found.
  • Outputs nothing if no matching media is found.

{getfilename}

Outputs the filename of one of the tag's files.

{getfilename:number}
number
Which file, starting at 1 for the first file.
{getfilename:1}
→The first file's name, e.g. image.png
  • Empty or non-numeric input leaves the function as plain text.
  • A file number that does not exist causes an error.

{image}

Get the URL of an image.

{image:query?}

Works like {media} but only matches images.

With no argument, the bot looks for the most recent matching media in this order: an attachment on a slash command, the message that ran the tag (attachments, embeds, stickers), the message it replies to, then the channel's last 25 messages (the ones the bot has cached first, then fetched if the bot can read message history).

With an argument, attachments on the message that ran the tag and the message it replies to still come first. After that the argument is read as: ^ (the last media, same as no argument), ^2 to ^99 (the media before that, counting back with the attachments and reply as the newest), a URL or a Discord message link (it takes the media from that message), a user mention, ID, @name or name#0000 (that user's avatar), a custom emoji (its image), a unicode emoji (its Twemoji image), or a member name search (their avatar).

queryoptional
A URL, message link, user, emoji or ^. Leave empty to use the last image in the channel.
{image}
→https://cdn.discordapp.com/attachments/.../cat.png
{image:{userid}}
→Your avatar URL
{settings:MEDIA_IV_FALLBACK|search.google.images}{image:{args}}
→An image from the arguments, or a Google Images result for them if none is found
  • Counts as 1 network request, even if nothing is found.
  • If nothing is found, a fallback set with {settings:MEDIA_IV_FALLBACK|...} runs instead, with the same argument (for example search.google.images, search.ddg.images or imagine, which generates an image and uses its temporary URL).
  • Outputs nothing if no matching media is found.

{iv}

Get the URL of an image or video.

{iv:query?}

Works like {media} but skips audio.

With no argument, the bot looks for the most recent matching media in this order: an attachment on a slash command, the message that ran the tag (attachments, embeds, stickers), the message it replies to, then the channel's last 25 messages (the ones the bot has cached first, then fetched if the bot can read message history).

With an argument, attachments on the message that ran the tag and the message it replies to still come first. After that the argument is read as: ^ (the last media, same as no argument), ^2 to ^99 (the media before that, counting back with the attachments and reply as the newest), a URL or a Discord message link (it takes the media from that message), a user mention, ID, @name or name#0000 (that user's avatar), a custom emoji (its image), a unicode emoji (its Twemoji image), or a member name search (their avatar).

queryoptional
A URL, message link, user, emoji, ^ or ^2 (the one before the last). Leave empty to use the last image/video in the channel.
{iv}
→https://cdn.discordapp.com/attachments/.../funny.gif
{iv:^2}
→https://cdn.discordapp.com/attachments/.../older.png
  • Counts as 1 network request, even if nothing is found.
  • If nothing is found, a fallback set with {settings:MEDIA_IV_FALLBACK|...} runs instead, with the same argument (for example search.google.images, search.ddg.images or imagine, which generates an image and uses its temporary URL).
  • Outputs nothing if no matching media is found.

{last_attachment}

lastattachmentlattachmentlattach

Outputs the URL of the most recent image.

{lastattachment}

Looks for an image in the triggering message first, then the message it replies to, then recent messages in the channel. For slash commands, an attached file is used.

{lastattachment}
→Something like "https://cdn.discordapp.com/attachments/.../image.png".
{attach:{lastattachment}|again.png}
→Re-uploads the last image as again.png.
  • Always counts against the network request limit.
  • Outputs nothing if no image is found. Any argument is ignored.

{media}

Get the URL of an image, video or audio file.

{media:query?}

With no argument, the bot looks for the most recent matching media in this order: an attachment on a slash command, the message that ran the tag (attachments, embeds, stickers), the message it replies to, then the channel's last 25 messages (the ones the bot has cached first, then fetched if the bot can read message history).

With an argument, attachments on the message that ran the tag and the message it replies to still come first. After that the argument is read as: ^ (the last media, same as no argument), ^2 to ^99 (the media before that, counting back with the attachments and reply as the newest), a URL or a Discord message link (it takes the media from that message), a user mention, ID, @name or name#0000 (that user's avatar), a custom emoji (its image), a unicode emoji (its Twemoji image), or a member name search (their avatar).

queryoptional
A URL, message link, user, emoji or ^. Leave empty to use the last media in the channel.
{media}
→https://cdn.discordapp.com/attachments/.../clip.mp4
{media:{args}}
→Media from whatever the user passed (a URL, a user's avatar, an emoji, ...)
  • Counts as 1 network request, even if nothing is found.
  • Outputs nothing if no matching media is found.

{medialist}

media.list

Get the URLs of several pieces of media as a JSON array.

{medialist:type?|max?|text?}

Collects media in this order: attachments on a slash command, the message that ran the tag (attachments, stickers), the message it replies to, then the text argument. It stops once it has max URLs.

Unlike {media}, it does not look through the channel's older messages, so a list is only what was sent or pointed at. Put ^ in the text to add the last media in the channel, or ^2 for the one before it.

A Discord message link in the text starts the list at that message instead of the one that ran the tag and its reply: every media in it, then the media sent before it in its channel until there are max URLs. So {medialist:video|10|LINK} is the linked message's videos, then older ones up to 10.

The text is read like {media}'s argument: URLs, Discord message links, user mentions, IDs, @name (their avatar), emojis and member name searches. Use it with {foreach} to go through each URL, or {traversejson} to pick or count them.

typeoptional
media (the default), image, video, audio, av (audio or video) or iv (image or video).
maxoptional
The most URLs to return, from 1 to 10. Defaults to 10.
textoptional
Extra media to look for, such as {args}.
{medialist}
→["https://cdn.discordapp.com/attachments/.../a.png","https://cdn.discordapp.com/attachments/.../b.mp4"]
{medialist:image|2|{args}}
→Up to two images from the message, the reply and the arguments
{medialist:video|10|https://discord.com/channels/.../.../...}
→The linked message's videos, then the ones sent before it, up to 10
{foreach:{medialist:image}|{attach:{get:valuex}}}
→Re-uploads every image on the message
{traversejson:length|{medialist}}
→2
  • Counts as 1 network request, even if nothing is found.
  • Outputs [] if no matching media is found.
  • An unknown type, or a max that isn't a number, leaves the function as plain text.

{mediascript}

mscriptimagescriptiscript

Run a MediaScript program and attach the file it produces.

{mediascript:code}

MediaScript is NotSoBot's scripting language for creating and editing images, video and audio. The code runs on NotSoBot's servers and the output file is attached to the tag's reply.

You can feed files the tag has already attached into the script by writing FILE_1, FILE_2, and so on (numbered in attachment order). Using FILE_1 moves that file into the script, so it is removed from the reply; use FILE_1_COPY to keep the original attached as well. Attachments that are only a link are replaced by their URL.

code
The MediaScript code to run. Whitespace around it is trimmed.
{attach:{image}}{mediascript:...your script using FILE_1...}
→Attaches the processed image in place of the original
  • Counts as 1 network request.
  • Safe mode is on unless the channel is NSFW (or a DM), following the usual NSFW rules.
  • Any image generation inside the script uses the model picked with {settings:ML_IMAGINE_MODEL|...}.
  • Values the script returns as arguments are saved as tag variables, as if set with {set}.
  • Text outputs (like .txt) are attached as text files.
  • Left as plain text if the code is empty or attachments are not allowed here.
  • Errors if FILE_n refers to a file that doesn't exist, the script errors, the tag already has the maximum number of attachments (10), or the result is larger than the upload limit.

{mediascriptmaybeurl}

mscriptmaybeurlimagescriptmaybeurliscriptmaybeurl

Runs MediaScript code and attaches the result, or outputs a URL to it when the API uploads it instead.

{mediascriptmaybeurl:code}

Works like {mediascript}, but the output file is not held to Discord's strict upload size. If the API returns an uploaded copy of the result, its URL is added to the text; otherwise the resulting file is attached to the reply.

code
The MediaScript code to run.
{image:https://cdn.nsb.gg/assets/samples/b1.png}{mscriptmaybeurl:...code using FILE_1...}
→The edited image, attached or as a link
  • Use FILE_1, FILE_2, ... in the code to refer to files the tag has already attached (in the order they were attached). Referenced files are handed to the script and removed from the tag's attachments; write FILE_1_COPY instead to keep the original attached as well. Referring to a file that does not exist is an error.
  • If the script returns variables, each one is set as a tag variable (as if you used {set}), so you can read them afterwards with {get}.
  • Counts as one network request.
  • Safe mode (NSFW filtering) follows the channel, and the image generation model follows the ML_IMAGINE_MODEL setting from {settings}.
  • An attached result larger than the max upload size is an error. A script error is shown as an error.
  • With empty code, the function is left in the output as plain text.

{mediascripturl}

mscripturlimagescripturliscripturl

Runs MediaScript code, uploads the result, and outputs its URL.

{mediascripturl:code}

Works like {mediascript}, but instead of attaching the result to the reply, the result is uploaded and its CDN URL is added to the text. Handy for passing a result into other functions or embeds.

code
The MediaScript code to run.
{image:https://cdn.nsb.gg/assets/samples/b1.png}{mscripturl:...code using FILE_1...}
→A URL to the edited image
  • Uploaded results expire after 7 days.
  • Use FILE_1, FILE_2, ... in the code to refer to files the tag has already attached (in the order they were attached). Referenced files are handed to the script and removed from the tag's attachments; write FILE_1_COPY instead to keep the original attached as well. Referring to a file that does not exist is an error.
  • If the script returns variables, each one is set as a tag variable (as if you used {set}), so you can read them afterwards with {get}.
  • Counts as one network request.
  • Safe mode (NSFW filtering) follows the channel, and the image generation model follows the ML_IMAGINE_MODEL setting from {settings}.
  • With empty code, the function is left in the output as plain text.

{ocr}

Reads the text in an image (OCR) and outputs it.

{ocr:image?}
imageoptional
Optional. An image URL, or something that points to an image (like a user or emoji). If left out, the most recent image in the chat is used.
{ocr}
→The text found in the last image in chat
{ocr:https://cdn.nsb.gg/assets/samples/captioned.png}
→The caption's text, when the bot works
  • Counts as a network request.
  • If no image is found, no text is detected or the request fails, nothing is output.
  • If no image is found and the MEDIA_IV_FALLBACK setting is set (see {settings}), that fallback function is run with the same argument to find an image instead.

{transcribe}

Transcribes the speech in an audio or video clip into text.

{transcribe:url?}

If no URL is given, the most recent audio/video in the chat (attachments, replies, etc.) is used. If none is found and the MEDIA_AV_FALLBACK setting is set (e.g. {settings:MEDIA_AV_FALLBACK|search.youtube}), that function is run with the same argument to find a URL instead.

urloptional
A link to an audio or video file. Defaults to the last audio/video found.
{transcribe}
→The spoken text of the last audio/video in the chat
{transcribe:https://cdn.nsb.gg/assets/samples/voice.mp3}
→The spoken text of voice.mp3
  • Counts as a network request.
  • If no media is found or transcription fails, nothing is output (no error).

{video}

Get the URL of a video.

{video:query?}

Works like {media} but only matches videos.

With no argument, the bot looks for the most recent matching media in this order: an attachment on a slash command, the message that ran the tag (attachments, embeds, stickers), the message it replies to, then the channel's last 25 messages (the ones the bot has cached first, then fetched if the bot can read message history).

With an argument, attachments on the message that ran the tag and the message it replies to still come first. After that the argument is read as: ^ (the last media, same as no argument), ^2 to ^99 (the media before that, counting back with the attachments and reply as the newest), a URL or a Discord message link (it takes the media from that message), a user mention, ID, @name or name#0000 (that user's avatar), a custom emoji (its image), a unicode emoji (its Twemoji image), or a member name search (their avatar).

queryoptional
A URL, message link or ^. Leave empty to use the last video in the channel.
{video}
→https://cdn.discordapp.com/attachments/.../clip.mp4
  • Counts as 1 network request, even if nothing is found.
  • Outputs nothing if no matching media is found.

AI

Generate text and images, and read what is in them.

{ai}

Asks NotSoBot's AI a question and outputs its answer.

{ai:prompt}

Sends the text to the AI and adds the generated reply to the output. The text can be wrapped in a code block, which gets stripped before sending.

You can give the AI media by putting load URL (or load URL filename) lines at the very top of the prompt. Files you created earlier in the tag with {attach} can be referenced as FILE_1, FILE_2, etc. Using FILE_1 moves that file into the AI request (it will no longer be sent with the message); use FILE_1_COPY to keep it.

The personality comes from {settings:AI_PERSONALITY|...} if set, otherwise your user or server AI personality. The model can be picked with {settings:AI_MODEL|...}.

prompt
What to ask. Optional load URL [filename] lines may come first.
{ai:write a haiku about {arg}}
→A haiku about the first argument, written by the AI.
{ai:load {lastattachment}
describe this image in one sentence}
→A one sentence description of the last image in the channel.
  • Counts against the AI execution limit (1 per run by default) and the network request limit.
  • The prompt is capped at 12,000 characters (including a short internal header with the AI execution count).
  • An empty prompt outputs nothing.
  • When used inside a tag, the reply is added as plain text. When the script comes from the AI itself, the reply is parsed as tagscript first (and counts as coming from NotSoAI for {isfromai}, but the NotSoAI-only functions are left as plain text in it, since its prompt can have anyone's text in it).
  • Using a FILE_N that does not exist throws an error.

{ai.knowledge.add}

Teaches NotSoAI a fact about the current server. Only NotSoAI can use this, for members with Manage Server.

{ai.knowledge.add:fact}

The fact is shown to NotSoAI in every future prompt from anyone in the server, numbered by position. Outputs true when added, or false if the server already had that fact (compared case-insensitively).

fact
The fact, like the server's rules or what a channel is for. Cut to 1000 characters.
{ai.knowledge.add:Memes go in #shitposting, not #general}
→true
  • Only NotSoAI can use this. In a user's tag (or a tag NotSoAI calls with {tag}) the function is left as plain text. It is also left as plain text when run from a button or menu NotSoAI made, since someone else could press it. When NotSoAI's prompt had someone else's text in it (another person's message it replied to, a link, a file that isn't the user's own upload, or the url option, earlier in the conversation too), or in code that only exists while running, like an {ai} reply or what {eval} and {evalsilent} run, it first asks the person with Allow and Cancel buttons (up to 3 times per message) and is left as plain text if they cancel or don't answer within a minute.
  • Needs the Manage Server permission, and only works in a server. Throws an error otherwise.
  • This permanently changes what NotSoAI knows about the server for everyone in it, not just this run. It can also be changed from the dashboard.
  • The ai.knowledge.* functions can change the server's knowledge at most 3 times per message; another change throws an error.
  • Counts against the network request limit.
  • An empty fact outputs nothing.
  • Throws an error if the server already has 10 facts, the facts would be over 1000 characters together, or the fact looks like a password, token or key.

{ai.knowledge.delete}

Removes one of NotSoAI's facts about the current server, by its position. Only NotSoAI can use this, for members with Manage Server.

{ai.knowledge.delete:position}

The position is the fact's number in the server's facts NotSoAI is shown in its prompt, starting at 1. Outputs true when removed.

position
The fact's number, starting at 1.
{ai.knowledge.delete:2}
→true
  • Only NotSoAI can use this. In a user's tag (or a tag NotSoAI calls with {tag}) the function is left as plain text. It is also left as plain text when run from a button or menu NotSoAI made, since someone else could press it. When NotSoAI's prompt had someone else's text in it (another person's message it replied to, a link, a file that isn't the user's own upload, or the url option, earlier in the conversation too), or in code that only exists while running, like an {ai} reply or what {eval} and {evalsilent} run, it first asks the person with Allow and Cancel buttons (up to 3 times per message) and is left as plain text if they cancel or don't answer within a minute.
  • Needs the Manage Server permission, and only works in a server. Throws an error otherwise.
  • This permanently changes what NotSoAI knows about the server for everyone in it, not just this run. It can also be changed from the dashboard.
  • The ai.knowledge.* functions can change the server's knowledge at most 3 times per message; another change throws an error.
  • Counts against the network request limit.
  • An empty argument outputs nothing.
  • Throws an error if the position is not a positive number or there is no fact at that position.
  • Positions stay the ones NotSoAI saw in its prompt for the whole reply, so {ai.knowledge.delete:1}{ai.knowledge.delete:2} removes the first two facts. A fact that was already removed throws an error.
  • Asks the person to confirm with Allow and Cancel buttons first, even when nobody else's text was in the prompt. It is left as plain text if they cancel or don't answer within a minute.

{ai.knowledge.edit}

Replaces one of NotSoAI's facts about the current server, by its position. Only NotSoAI can use this, for members with Manage Server.

{ai.knowledge.edit:position|fact}

The position is the fact's number in the server's facts NotSoAI is shown in its prompt, starting at 1. Outputs true when replaced.

position
The fact's number, starting at 1.
fact
The new fact. Cut to 1000 characters.
{ai.knowledge.edit:1|Movie night is on Fridays now}
→true
  • Only NotSoAI can use this. In a user's tag (or a tag NotSoAI calls with {tag}) the function is left as plain text. It is also left as plain text when run from a button or menu NotSoAI made, since someone else could press it. When NotSoAI's prompt had someone else's text in it (another person's message it replied to, a link, a file that isn't the user's own upload, or the url option, earlier in the conversation too), or in code that only exists while running, like an {ai} reply or what {eval} and {evalsilent} run, it first asks the person with Allow and Cancel buttons (up to 3 times per message) and is left as plain text if they cancel or don't answer within a minute.
  • Needs the Manage Server permission, and only works in a server. Throws an error otherwise.
  • This permanently changes what NotSoAI knows about the server for everyone in it, not just this run. It can also be changed from the dashboard.
  • The ai.knowledge.* functions can change the server's knowledge at most 3 times per message; another change throws an error.
  • Counts against the network request limit.
  • Outputs nothing if the position or the fact is empty.
  • Throws an error if the position is not a positive number, there is no fact at that position, or the facts would be over 1000 characters together.
  • Positions stay the ones NotSoAI saw in its prompt for the whole reply, so after {ai.knowledge.delete:1}, {ai.knowledge.edit:2|…} still changes the fact that was second. A fact that was already removed throws an error.

{ai.listen.stop}

Ends the ai listen voice conversation in the current server. Only NotSoAI can use this.

{ai.listen.stop}

NotSoAI uses it when the person it's listening to says goodbye or asks it to stop listening. It stops listening straight away, but what it's already saying still plays, so a spoken goodbye finishes. Outputs true when it stopped, or false when it wasn't listening in this server.

{ai.listen.stop}
→true
  • Only NotSoAI can use this. In a user's tag (or a tag NotSoAI calls with {tag}) the function is left as plain text. It is also left as plain text when run from a button or menu NotSoAI made, since someone else could press it. When NotSoAI's prompt had someone else's text in it (another person's message it replied to, a link, a file that isn't the user's own upload, or the url option, earlier in the conversation too), or in code that only exists while running, like an {ai} reply or what {eval} and {evalsilent} run, it first asks the person with Allow and Cancel buttons (up to 3 times per message) and is left as plain text if they cancel or don't answer within a minute.
  • Only the person NotSoAI is listening to, or a DJ (Manage Server, the DJ role, or Manage Channel on the bot's voice channel), can stop it. Throws an error for anyone else.
  • Outputs false outside a server.
  • Typing ai listen stop ends it too, and also cuts off what NotSoAI is saying.

{ai.memory.add}

Saves a fact about the person using NotSoAI to its memory. Only NotSoAI can use this.

{ai.memory.add:fact|server?}

The fact is shown to NotSoAI in every future prompt from that person. By default it is remembered everywhere; pass server to only remember it in the current server. Outputs true when saved, or false if NotSoAI already remembered that fact (compared case-insensitively).

fact
The fact to remember. Cut to 200 characters.
serveroptional
server to only remember it in this server. Ignored in DMs, where it is remembered everywhere.
{ai.memory.add:Prefers to be called Sam}
→true
{ai.memory.add:Is a moderator here|server}
→true (only remembered in this server)
  • Only NotSoAI can use this. In a user's tag (or a tag NotSoAI calls with {tag}) the function is left as plain text. It is also left as plain text when run from a button or menu NotSoAI made, since someone else could press it. When NotSoAI's prompt had someone else's text in it (another person's message it replied to, a link, a file that isn't the user's own upload, or the url option, earlier in the conversation too), or in code that only exists while running, like an {ai} reply or what {eval} and {evalsilent} run, it first asks the person with Allow and Cancel buttons (up to 3 times per message) and is left as plain text if they cancel or don't answer within a minute.
  • This permanently changes NotSoAI's memory of the person who asked it, not just this run.
  • The ai.memory.* functions can change the memory at most 3 times per message; another change throws an error. An add only counts when it saves something new.
  • Counts against the network request limit.
  • An empty fact outputs nothing.
  • Throws an error if the person turned off NotSoAI's memory, already has 25 global memories (or 15 for this server, with server), or the fact looks like a password, token or key.

{ai.memory.clear}

Forgets everything NotSoAI remembers about the person using it. Only NotSoAI can use this.

{ai.memory.clear}

Deletes all of the person's memories, including the ones saved for other servers. Outputs how many memories were forgotten.

{ai.memory.clear}
→4
  • Only NotSoAI can use this. In a user's tag (or a tag NotSoAI calls with {tag}) the function is left as plain text. It is also left as plain text when run from a button or menu NotSoAI made, since someone else could press it. When NotSoAI's prompt had someone else's text in it (another person's message it replied to, a link, a file that isn't the user's own upload, or the url option, earlier in the conversation too), or in code that only exists while running, like an {ai} reply or what {eval} and {evalsilent} run, it first asks the person with Allow and Cancel buttons (up to 3 times per message) and is left as plain text if they cancel or don't answer within a minute.
  • This permanently changes NotSoAI's memory of the person who asked it, not just this run.
  • The ai.memory.* functions can change the memory at most 3 times per message; another change throws an error. A clear only counts when something was forgotten.
  • Counts against the network request limit.
  • Asks the person to confirm with Allow and Cancel buttons first, even when nobody else's text was in the prompt. It is left as plain text if they cancel or don't answer within a minute.

{ai.memory.delete}

Forgets one of NotSoAI's memories about the person using it, by its position. Only NotSoAI can use this.

{ai.memory.delete:position}

The position is the memory's number in the list of memories NotSoAI is shown in its prompt, starting at 1. Outputs true when deleted.

position
The memory's number, starting at 1.
{ai.memory.delete:2}
→true
  • Only NotSoAI can use this. In a user's tag (or a tag NotSoAI calls with {tag}) the function is left as plain text. It is also left as plain text when run from a button or menu NotSoAI made, since someone else could press it. When NotSoAI's prompt had someone else's text in it (another person's message it replied to, a link, a file that isn't the user's own upload, or the url option, earlier in the conversation too), or in code that only exists while running, like an {ai} reply or what {eval} and {evalsilent} run, it first asks the person with Allow and Cancel buttons (up to 3 times per message) and is left as plain text if they cancel or don't answer within a minute.
  • This permanently changes NotSoAI's memory of the person who asked it, not just this run.
  • The ai.memory.* functions can change the memory at most 3 times per message; another change throws an error.
  • Counts against the network request limit.
  • An empty argument outputs nothing.
  • Throws an error if the position is not a positive number or there is no memory at that position.

{ai.memory.edit}

Replaces one of NotSoAI's memories about the person using it, by its position. Only NotSoAI can use this.

{ai.memory.edit:position|fact}

The position is the memory's number in the list of memories NotSoAI is shown in its prompt, starting at 1. Outputs true when replaced.

position
The memory's number, starting at 1.
fact
The new fact. Cut to 200 characters.
{ai.memory.edit:1|Prefers to be called Alex now}
→true
  • Only NotSoAI can use this. In a user's tag (or a tag NotSoAI calls with {tag}) the function is left as plain text. It is also left as plain text when run from a button or menu NotSoAI made, since someone else could press it. When NotSoAI's prompt had someone else's text in it (another person's message it replied to, a link, a file that isn't the user's own upload, or the url option, earlier in the conversation too), or in code that only exists while running, like an {ai} reply or what {eval} and {evalsilent} run, it first asks the person with Allow and Cancel buttons (up to 3 times per message) and is left as plain text if they cancel or don't answer within a minute.
  • This permanently changes NotSoAI's memory of the person who asked it, not just this run.
  • The ai.memory.* functions can change the memory at most 3 times per message; another change throws an error.
  • Counts against the network request limit.
  • Outputs nothing if the position or the fact is empty.
  • Throws an error if the position is not a positive number or there is no memory at that position.

{edit}

Edit an image with AI from a text prompt and attach the result.

{edit:prompt?|image?}

Finds an image (the same way {image} does) and asks the AI image editor to change it based on your prompt. The edited image is attached to the tag's reply. If the prompt is empty, one is made up automatically.

promptoptional
What to change. If there is a |, everything before the last | is the prompt.
imageoptional
Where to find the image (URL, user, emoji, ^...). Only read if there is a |; otherwise the last image is used.
{edit:make it look like a watercolor painting}
→Attaches an edited version of the last image
{edit:give them a party hat|{userid}}
→Attaches your avatar wearing a party hat
{edit:|{args}}
→Attaches an edit of the given image with an automatic prompt
  • Counts as 1 network request and 1 AI request (5 AI requests per run by default).
  • Always runs in safe mode.
  • Uses the model picked with {settings:ML_IMAGINE_MODEL|...} (currently only FLUX_KLEIN); {settings:ML_IMAGINE_DO_NOT_ERROR|true} is passed along too.
  • If nothing is found, a fallback set with {settings:MEDIA_IV_FALLBACK|...} runs instead, with the same argument (for example search.google.images, search.ddg.images or imagine, which generates an image and uses its temporary URL).
  • Left as plain text if no image is found, or if attachments are not allowed here.
  • Errors if the tag already has the maximum number of attachments (10), or if the result is larger than the upload limit.

{editurl}

Edit an image with AI and output a link to the result.

{editurl:prompt?|image?}

Same as {edit}, but instead of attaching the image it uploads it and outputs the URL, so you can use it in embeds or pass it to other functions.

promptoptional
What to change. If there is a |, everything before the last | is the prompt.
imageoptional
Where to find the image. Only read if there is a |; otherwise the last image is used.
{editurl:turn it into pixel art}
→https://.../edited.png
Here you go: {editurl:make it night time|{args}}
→Here you go: https://.../edited.png
  • Counts as 1 network request and 1 AI request (5 AI requests per run by default).
  • Always runs in safe mode.
  • The uploaded link expires after 7 days.
  • Uses the model picked with {settings:ML_IMAGINE_MODEL|...}.
  • If nothing is found, a fallback set with {settings:MEDIA_IV_FALLBACK|...} runs instead, with the same argument (for example search.google.images, search.ddg.images or imagine, which generates an image and uses its temporary URL).
  • Outputs nothing if no image is found.

{identify}

interrogate

Describes an image in detail with AI, outputting a few sentences about what it shows.

{identify:image?[|model]}
imageoptional
Optional. An image URL, or something that points to an image (like a user or emoji). If left out, the most recent image in the chat is used.
modeloptional
Florence-2: florence (default) for a detailed paragraph, florence-medium for 2-3 sentences or florence-short for one sentence (the shorter, the faster). The old CLIP Interrogator, for image generation prompts and faster: clip for a short caption followed by art-style tags, clip-classic for "caption, medium by artist, trending, movement, flavors", or clip-negative for the phrases least like the image (a negative prompt). Case-insensitive, _ works instead of -. Only treated as the model if the last | part is one of these; otherwise it stays part of the image argument.
{identify}
→A description of the last image in chat, e.g. "A gray cat sitting on a laptop keyboard on a wooden desk..."
{identify:{avatar}}
→A description of your avatar
{identify:|clip}
→A prompt for the last image in chat, e.g. "a cat sitting on a laptop keyboard, by greg rutkowski, trending on artstation, ..."
{identify:{avatar}|florence-short}
→One sentence about your avatar
  • Counts as a network request.
  • If no image is found or the request fails, nothing is output.
  • If no image is found and the MEDIA_IV_FALLBACK setting is set (see {settings}), that fallback function is run with the same argument to find an image instead.

{imagine}

Generate an image with AI and attach it.

{imagine:prompt?}

Creates a brand new image from a text prompt and attaches it to the tag's reply. If the prompt is empty, one is made up automatically.

promptoptional
What the image should show.
{imagine:a cat wearing a tiny crown}
→Attaches a generated image of a crowned cat
{imagine}
→Attaches an image from a random prompt
{settings:ML_IMAGINE_MODEL|FLUX_KLEIN}{imagine:{args}}
→Generates with the Flux Klein model
  • Counts as 1 network request and 1 AI request (5 AI requests per run by default).
  • Always runs in safe mode.
  • Uses the model picked with {settings:ML_IMAGINE_MODEL|...} (currently only FLUX_KLEIN); {settings:ML_IMAGINE_DO_NOT_ERROR|true} is passed along too.
  • Left as plain text if attachments are not allowed here.
  • Errors if the tag already has the maximum number of attachments (10), or if the result is larger than the upload limit.

{imagineurl}

Generate an image with AI and output a link to it.

{imagineurl:prompt?}

Same as {imagine}, but uploads the image and outputs its URL instead of attaching it.

promptoptional
What the image should show.
{imagineurl:a sunset over the ocean}
→https://.../image.png
{set:art|{imagineurl:{args}}}Your art: {get:art}
→Your art: https://.../image.png
  • Counts as 1 network request and 1 AI request (5 AI requests per run by default).
  • Always runs in safe mode.
  • The uploaded link expires after 7 days.
  • Uses the model picked with {settings:ML_IMAGINE_MODEL|...}.

{settings.set.server}

Reads or changes this server's settings, like its timezone or search provider. Only NotSoAI can use this, for members with Manage Server.

{settings.set.server:setting?|value?}

With no arguments, outputs every server setting as a JSON object. With just a setting, outputs its current value. With a value, saves it and outputs true, or false if it was already set to that. Use clear to reset it, so everyone falls back to their own setting and then the default.

The settings are AI_MODEL, AI_PERSONALITY, IMAGINE_MODEL, LOCALE, MEDIA_FONT (the Default Font for caption, meme and recaption: a built-in font like IMPACT, or one of the server's saved fonts by name), RESPONSE_DISPLAY (DEFAULT/NO_EMBED/LEGACY), SEARCH_PROVIDER_IMAGES and SEARCH_PROVIDER_WEB (GOOGLE/DUCK_DUCK_GO/BING/YANDEX) and TIMEZONE.

settingoptional
Which setting, like TIMEZONE or search provider web. Leave out to output every setting.
valueoptional
The new value, or clear to reset it. Leave out to read the current one.
{settings.set.server:SEARCH_PROVIDER_WEB|bing}
→true
{settings.set.server:TIMEZONE}
→Europe/London
  • Only NotSoAI can use this, and only in its own reply: in a user's tag, or a button NotSoAI made, the function is left as plain text. When NotSoAI's prompt had someone else's text in it (another person's message it replied to, a link, a file that isn't the user's own upload, or the url option, earlier in the conversation too), or in code that only exists while running, like an {ai} reply or what {eval} and {evalsilent} run, it first asks the person with Allow and Cancel buttons (up to 3 times per message) and is left as plain text if they cancel or don't answer within a minute.
  • The person who asked NotSoAI needs the Manage Server permission, even just to read the settings. Otherwise it throws an error.
  • Only works in a server.
  • This permanently changes the server's NotSoBot settings for everyone, not just this run.

{settings.set.server.ai.personality}

Reads, sets or clears this server's NotSoAI personality. Only NotSoAI can use this, for members with Manage Server.

{settings.set.server.ai.personality:prompt?}

The same as {settings.set.server} with AI_PERSONALITY, but the whole argument is the personality, so it can contain |.

promptoptional
The personality prompt, or clear to clear it. Leave out to read the current one.
{settings.set.server.ai.personality:talk like a pirate}
→true
  • Only NotSoAI can use this, and only in its own reply: in a user's tag, or a button NotSoAI made, the function is left as plain text. The person who asked needs the Manage Server permission. When NotSoAI's prompt had someone else's text in it (another person's message it replied to, a link, a file that isn't the user's own upload, or the url option, earlier in the conversation too), or in code that only exists while running, like an {ai} reply or what {eval} and {evalsilent} run, it first asks the person with Allow and Cancel buttons (up to 3 times per message) and is left as plain text if they cancel or don't answer within a minute.
  • NotSoBot filters the personality before saving it.

{settings.set.user}

Reads or changes the other settings of the person using the tag, like their units or AI model. Only NotSoAI can use this.

{settings.set.user:setting?|value?}

With no arguments, outputs every setting (plus AI_PERSONALITY, LOCALE and TIMEZONE) as a JSON object. With just a setting, outputs its current value. With a value, saves it and outputs true, or false if it was already set to that. Use clear to reset it to the default.

The settings are AI_MEMORY (on/off), AI_MODEL, APP_COMMAND_RESPONSE_TYPE (AUTOMATIC/EPHEMERAL), DOWNLOAD_QUALITY (1440p to 144p), FALLBACKS_MEDIA_IMAGE (SEARCH_GOOGLE_IMAGES/SEARCH_DUCK_DUCK_GO_IMAGES/IMAGINE), FILE_UPLOAD_THRESHOLD (EXCEEDS_DISCORD_LIMIT/ALWAYS/NEVER), FILE_UPLOAD_TYPE (AUTOMATIC/TEMPORARY), FILE_VANITY, IMAGINE_MODEL, MEDIA_FONT (the Default Font for caption, meme and recaption: a built-in font like IMPACT, or one of your saved fonts by name), RESPONSE_DISPLAY (DEFAULT/NO_EMBED/LEGACY), SEARCH_PROVIDER_IMAGES and SEARCH_PROVIDER_WEB (GOOGLE/DUCK_DUCK_GO/BING/YANDEX), TTS_VOICE (a built-in voice like TIKTOK_EN_US_FEMALE_01, or one of your cloned voices by name) and UNITS (IMPERIAL/METRIC).

settingoptional
Which setting, like UNITS or ai model. Leave out to output every setting.
valueoptional
The new value, or clear to reset it. Leave out to read the current one.
{settings.set.user:UNITS|metric}
→true
{settings.set.user:UNITS}
→METRIC
{settings.set.user:AI_MEMORY|off}
→true
  • Only NotSoAI can use this. In a user's tag (or a tag NotSoAI calls with {tag}) the function is left as plain text. It is also left as plain text when run from a button or menu NotSoAI made, since someone else could press it. When NotSoAI's prompt had someone else's text in it (another person's message it replied to, a link, a file that isn't the user's own upload, or the url option, earlier in the conversation too), or in code that only exists while running, like an {ai} reply or what {eval} and {evalsilent} run, it first asks the person with Allow and Cancel buttons (up to 3 times per message) and is left as plain text if they cancel or don't answer within a minute.
  • This permanently changes the NotSoBot settings of the person who asked NotSoAI, not just this run.
  • Language, timezone and AI personality have their own functions: {settings.set.user.locale}, {settings.set.user.timezone} and {settings.set.user.ai.personality}.
  • Throws an error if the setting or value is not recognised, or if the setting needs premium.

{settings.set.user.ai.personality}

Reads or changes the AI personality saved in the settings of the person using the tag. Only NotSoAI can use this.

{settings.set.user.ai.personality:prompt?}

With no argument, outputs the user's current AI personality (or nothing if they have none). With a prompt, saves it as their personality and outputs true, or false if it was already set to that. Use clear to remove it.

promptoptional
The new personality prompt, or clear to remove it. Leave out to read the current one.
{settings.set.user.ai.personality}
→The current personality prompt
{settings.set.user.ai.personality:You are a grumpy pirate.}
→true
{settings.set.user.ai.personality:clear}
→true (or false if none was set)
  • Only NotSoAI can use this. In a user's tag (or a tag NotSoAI calls with {tag}) the function is left in the output as plain text. It is also left as plain text when run from a button or menu NotSoAI made, since someone else could press it. When NotSoAI's prompt had someone else's text in it (another person's message it replied to, a link, a file that isn't the user's own upload, or the url option, earlier in the conversation too), or in code that only exists while running, like an {ai} reply or what {eval} and {evalsilent} run, it first asks the person with Allow and Cancel buttons (up to 3 times per message) and is left as plain text if they cancel or don't answer within a minute.
  • This permanently changes the NotSoBot settings of the person who asked NotSoAI, not just this run.

{settings.set.user.locale}

Reads or changes the language saved in the settings of the person using the tag. Only NotSoAI can use this.

{settings.set.user.locale:locale?}

With no argument, outputs the user's current locale (or nothing if they have none). With a language name or code, saves it and outputs true, or false if it was already set to that. Use clear to remove it.

localeoptional
A language name or code like spanish or es, or clear to remove it. Leave out to read the current one.
{settings.set.user.locale:spanish}
→true
  • Only NotSoAI can use this. In a user's tag (or a tag NotSoAI calls with {tag}) the function is left as plain text. It is also left as plain text when run from a button or menu NotSoAI made, since someone else could press it. When NotSoAI's prompt had someone else's text in it (another person's message it replied to, a link, a file that isn't the user's own upload, or the url option, earlier in the conversation too), or in code that only exists while running, like an {ai} reply or what {eval} and {evalsilent} run, it first asks the person with Allow and Cancel buttons (up to 3 times per message) and is left as plain text if they cancel or don't answer within a minute.
  • This permanently changes the NotSoBot settings of the person who asked NotSoAI, not just this run.
  • Throws an error if the language is not recognised.

{settings.set.user.timezone}

Reads or changes the timezone saved in the settings of the person using the tag. Only NotSoAI can use this.

{settings.set.user.timezone:timezone?}

The timezone is used when reading reminder times like "at 4pm". With no argument, outputs the user's current timezone (or nothing if they have none). With a timezone, saves it and outputs true, or false if it was already set to that. Use clear to remove it.

timezoneoptional
An IANA name like America/New_York, an abbreviation like EST, or a city/region name, or clear to remove it. Leave out to read the current one.
{settings.set.user.timezone:America/New_York}
→true
{settings.set.user.timezone}
→America/New_York
  • Only NotSoAI can use this. In a user's tag (or a tag NotSoAI calls with {tag}) the function is left as plain text. It is also left as plain text when run from a button or menu NotSoAI made, since someone else could press it. When NotSoAI's prompt had someone else's text in it (another person's message it replied to, a link, a file that isn't the user's own upload, or the url option, earlier in the conversation too), or in code that only exists while running, like an {ai} reply or what {eval} and {evalsilent} run, it first asks the person with Allow and Cancel buttons (up to 3 times per message) and is left as plain text if they cancel or don't answer within a minute.
  • This permanently changes the NotSoBot settings of the person who asked NotSoAI, not just this run.
  • Throws an error if the timezone is not recognised.

Network

Fetch pages and call APIs.

{api.create.reminder}

Creates a reminder for the user and outputs it as JSON. Only NotSoAI can use this.

{api.create.reminder:time[|text]}

The time is parsed the same way the reminder command parses it (things like "in 5 minutes" or "tomorrow at 4pm"). If no text is given, any leftover words from the time text are used instead. Outputs an object like {"id": string, "position": number, "content": string, "timestamp_start": string, ...}.

time
A natural-language time, e.g. in 2 hours or next friday at 4pm do laundry.
textoptional
The reminder text. Defaults to the non-time words from time. Everything after the first | is used.
{api.create.reminder:in 2 hours|drink water}
→Creates the reminder and outputs its JSON.
  • Only NotSoAI can use this. In a user's tag (or a tag NotSoAI calls with {tag}) the function is left as plain text. It is also left as plain text when run from a button or menu NotSoAI made, since someone else could press it. When NotSoAI's prompt had someone else's text in it (another person's message it replied to, a link, a file that isn't the user's own upload, or the url option, earlier in the conversation too), or in code that only exists while running, like an {ai} reply or what {eval} and {evalsilent} run, it first asks the person with Allow and Cancel buttons (up to 3 times per message) and is left as plain text if they cancel or don't answer within a minute.
  • Counts against the API manipulation limit (1 per run by default) and the network request limit.
  • Throws an error if no time can be found in time.
  • An empty argument outputs nothing.

{api.create.report}

Sends a bug report or feedback to the NotSoBot staff. Only NotSoAI can use this.

{api.create.report:text}

Sends a bug report from the person who asked NotSoAI, like report bug, and outputs the report's ID. Staff answer it in the person's reports on the dashboard.

text
What went wrong, up to 2000 characters.
{api.create.report:.caption cuts off the last line on tall images}
→1234567890123456789
  • Only NotSoAI can use this. In a user's tag (or a tag NotSoAI calls with {tag}) the function is left as plain text. It is also left as plain text when run from a button or menu NotSoAI made, since someone else could press it. When NotSoAI's prompt had someone else's text in it (another person's message it replied to, a link, a file that isn't the user's own upload, or the url option, earlier in the conversation too), or in code that only exists while running, like an {ai} reply or what {eval} and {evalsilent} run, it first asks the person with Allow and Cancel buttons (up to 3 times per message) and is left as plain text if they cancel or don't answer within a minute.
  • Only bug reports and feedback. Reports about a person, server, message or tag still go through the report commands.
  • NotSoAI can send one report per message.
  • Counts against the network request limit.
  • An empty text outputs nothing.

{api.delete.reminder}

Deletes one of the user's reminders by its position. Only NotSoAI can use this.

{api.delete.reminder:position}

The position is the position field from {api.fetch.reminders}. Outputs true when deleted.

position
The reminder's position number.
{api.delete.reminder:1}
→true
  • Only NotSoAI can use this. In a user's tag (or a tag NotSoAI calls with {tag}) the function is left as plain text. It is also left as plain text when run from a button or menu NotSoAI made, since someone else could press it. When NotSoAI's prompt had someone else's text in it (another person's message it replied to, a link, a file that isn't the user's own upload, or the url option, earlier in the conversation too), or in code that only exists while running, like an {ai} reply or what {eval} and {evalsilent} run, it first asks the person with Allow and Cancel buttons (up to 3 times per message) and is left as plain text if they cancel or don't answer within a minute.
  • Counts against the API manipulation limit (1 per run by default) and the network request limit.
  • Throws an error if the position is not a positive number or no reminder exists there.
  • An empty argument outputs nothing.

{api.edit.reminder}

Changes the time and/or text of one of the user's reminders. Only NotSoAI can use this.

{api.edit.reminder:position|time[|text]}

The position is the position field from {api.fetch.reminders}. Leave time empty to keep the current time, and leave out text to keep the current text. Outputs the edited reminder as JSON.

position
The reminder's position number.
time
A new natural-language time, or empty to keep the current one.
textoptional
The new reminder text. Everything after the second | is used.
{api.edit.reminder:1|tomorrow at 9am}
→Moves reminder 1 to tomorrow at 9am and outputs its JSON.
{api.edit.reminder:2||buy milk}
→Changes reminder 2's text and outputs its JSON.
  • Only NotSoAI can use this. In a user's tag (or a tag NotSoAI calls with {tag}) the function is left as plain text. It is also left as plain text when run from a button or menu NotSoAI made, since someone else could press it. When NotSoAI's prompt had someone else's text in it (another person's message it replied to, a link, a file that isn't the user's own upload, or the url option, earlier in the conversation too), or in code that only exists while running, like an {ai} reply or what {eval} and {evalsilent} run, it first asks the person with Allow and Cancel buttons (up to 3 times per message) and is left as plain text if they cancel or don't answer within a minute.
  • Counts against the API manipulation limit (1 per run by default) and the network request limit.
  • Throws an error if the position is not a positive number, no reminder exists there, or the new time is in the past.

{api.fetch.commands}

Outputs the user's last few commands in this channel as JSON. Only NotSoAI can use this.

{api.fetch.commands}

Outputs an object like {"commands": [...]} with the person's last 5 commands in the current channel, newest first. Each one has command (the command's ID), timestamp, input (the message they typed, the first 200 characters, null for slash commands) and output with the reply's text (the first 200 characters) and files (its attachment and embed image or video URLs). output is null when the reply was deleted.

{traversejson:commands[0].output.files[0]|{api.fetch.commands}}
→The first file of the user's last command's reply.
  • Only NotSoAI can use this. In a user's tag (or a tag NotSoAI calls with {tag}) the function is left as plain text. It is also left as plain text when run from a button or menu NotSoAI made, since someone else could press it. When NotSoAI's prompt had someone else's text in it (another person's message it replied to, a link, a file that isn't the user's own upload, or the url option, earlier in the conversation too), or in code that only exists while running, like an {ai} reply or what {eval} and {evalsilent} run, it first asks the person with Allow and Cancel buttons (up to 3 times per message) and is left as plain text if they cancel or don't answer within a minute.
  • Counts against the network request limit once, and once more for each message that isn't cached.

{api.fetch.music}

Outputs what's playing in the server and the queue as JSON. Only NotSoAI can use this.

{api.fetch.music}

Outputs an object with playing, paused, channel_id (the voice channel, null when not in one), loop, dj_only, current (what's playing, null if nothing), queue (the next 10) and queue_count. Each track has title, artist, duration (milliseconds), url, queued_by (a user ID) and position (the number music queue shows, 1 is what's playing).

{traversejson:current.title|{api.fetch.music}}
→The title of the song that's playing.
  • Only NotSoAI can use this. In a user's tag (or a tag NotSoAI calls with {tag}) the function is left as plain text. It is also left as plain text when run from a button or menu NotSoAI made, since someone else could press it. When NotSoAI's prompt had someone else's text in it (another person's message it replied to, a link, a file that isn't the user's own upload, or the url option, earlier in the conversation too), or in code that only exists while running, like an {ai} reply or what {eval} and {evalsilent} run, it first asks the person with Allow and Cancel buttons (up to 3 times per message) and is left as plain text if they cancel or don't answer within a minute.
  • Only works in a server.
  • Counts against the network request limit.

{api.fetch.reminders}

Outputs the user's reminders as JSON. Only NotSoAI can use this.

{api.fetch.reminders[:global]}

Outputs an object like {"count": number, "reminders": [...]} with the same reminder fields as {api.create.reminder}. Only reminders in the current server are listed unless global is passed.

globaloptional
Pass global to list reminders from every server.
{traversejson:count|{api.fetch.reminders}}
→How many reminders the user has in this server.
  • Only NotSoAI can use this. In a user's tag (or a tag NotSoAI calls with {tag}) the function is left as plain text. It is also left as plain text when run from a button or menu NotSoAI made, since someone else could press it. When NotSoAI's prompt had someone else's text in it (another person's message it replied to, a link, a file that isn't the user's own upload, or the url option, earlier in the conversation too), or in code that only exists while running, like an {ai} reply or what {eval} and {evalsilent} run, it first asks the person with Allow and Cancel buttons (up to 3 times per message) and is left as plain text if they cancel or don't answer within a minute.
  • Counts against the network request limit.

{api.utilities.qr.create}

Attaches a QR code image of some text.

{api.utilities.qr.create:text}

Adds the QR code as a file attachment on the tag's output.

text
The text or url to encode.
{api.utilities.qr.create:https://notsobot.com}
→Attaches a QR code that opens the NotSoBot site.
  • Counts against the attachment limit and the network request limit.
  • An empty argument outputs nothing.

{api.utilities.qr.scan}

Scans an image for QR codes and outputs the results as JSON.

{api.utilities.qr.scan[:url]}

Outputs an object like {"results": [{"data": string, "type": string}]}. With no argument, the last image in the chat is used.

urloptional
An image url, user, or emoji. Defaults to the last image in the chat.
{traversejson:results[0].data|{api.utilities.qr.scan}}
→The contents of the first QR code found.
  • Counts against the network request limit.
  • Throws an error if no image can be found.

{api.utilities.screenshot}

Attaches a screenshot of a website.

{api.utilities.screenshot:url[|browser]}

Adds the screenshot as a file attachment on the tag's output. NSFW sites are blocked unless the channel is marked NSFW.

url
The website to screenshot.
browseroptional
chrome (default) or firefox (case-insensitive). Firefox can get past more bot checks but has no WebGL. Only treated as the browser if the last | part is one of these; otherwise it stays part of the url.
{api.utilities.screenshot:https://notsobot.com}
→Attaches a screenshot of the NotSoBot site.
{api.utilities.screenshot:https://notsobot.com|firefox}
→The same, taken with Firefox.
  • Counts against the attachment limit and the network request limit.
  • An empty argument outputs nothing.

{download}

text

Downloads a URL and outputs its contents as text.

{download:url}
url
The URL to download.
{download:https://example.com/file.txt}
→The contents of file.txt
{traversejson:name|{download:https://example.com/data.json}}
→The name field of a downloaded JSON file
  • Counts as a network request.
  • Errors if the downloaded text would push the tag's output past the max attachment size for the current context.

{downloadfromhtml}

textfromhtml

Downloads a web page and outputs its text with the HTML stripped out.

{downloadfromhtml:url}
url
The URL of the page to download.
{downloadfromhtml:https://example.com}
→The readable text of the page, without HTML tags
  • Counts as a network request.
  • Errors if the text would push the tag's output past the max attachment size for the current context.

{music.control}

Pauses, resumes, skips, seeks, loops or leaves, or sets the volume, speed or effects of the music playing in the server. Only NotSoAI can use this.

{music.control:action|value?}

Follows the same rules as the music commands: the person has to be in the voice channel the music is playing in. For pause, resume and skip, with DJ mode on (or the server's vote skip, pause or resume on) it counts as their vote unless they're a DJ (Manage Server, the DJ role, or Manage Channel on that voice channel). Everything else needs a DJ when DJ mode is on.

leave keeps the queue and where the song was, like pressing Keep on music leave, so music play or music resume carries on later. With nothing queued it just leaves.

Outputs true when it happened, false when there was nothing to change (already paused or playing, already that loop, or the effect wasn't on), or voted 1/3 when more votes are needed.

action
pause, resume, skip, volume, speed, effect_add, effect_remove, effect_clear, seek, loop or leave.
valueoptional
For volume, 0 to 200 (150 or 150%), or reset for 100. For speed, 0.5x to 2x (1.25, 125%), the pitch is kept. Anything but 100% volume or 1x speed needs a premium server. For effect_add and effect_remove, an effect: 8d, 8dvertical, bassboost, chipmunk, concerthall, crossfeed, daycore, deep, distortion, dreamy, echo, filtersweep, karaoke, lofi, mono, nextroom, nightcore, normalizer, oldrecord, phaser, radio, robot, slowed, trebleboost, tremolo, underwater, vaporwave, vibrato, wide (adding one needs a premium server). For seek, a time like 1:30 or 90. For loop, off, track or queue.
{music.control:skip}
→true
{music.control:volume|150}
→true
{music.control:effect_add|nightcore}
→true
{music.control:loop|track}
→true
  • Only NotSoAI can use this. In a user's tag (or a tag NotSoAI calls with {tag}) the function is left as plain text. It is also left as plain text when run from a button or menu NotSoAI made, since someone else could press it. When NotSoAI's prompt had someone else's text in it (another person's message it replied to, a link, a file that isn't the user's own upload, or the url option, earlier in the conversation too), or in code that only exists while running, like an {ai} reply or what {eval} and {evalsilent} run, it first asks the person with Allow and Cancel buttons (up to 3 times per message) and is left as plain text if they cancel or don't answer within a minute.
  • Up to 5 effects stack and they stay on for the next tracks. Some don't go together, like nightcore with slowed, and it errors saying which one is in the way.
  • It can't remove tracks or make the bot join, {music.play} queues them. Resuming after the bot left needs music resume.
  • NotSoAI can control the music at most 3 times per message.
  • Counts against the network request limit.

{music.identify}

The song the server's music is on right now. Only NotSoAI can use this.

{music.identify}

A song queued by name or by a service link is already known, so songs is null and track has its title and artist. A link or file (a mix, a long video, an mp3) is identified from where it's playing, like {api.audio.identify}.

Outputs JSON: {position: number, songs: Array<Song> | null, track: Item}. position is where it's playing in milliseconds, Song is shaped like {api.audio.identify}'s (best first, [] when it wasn't recognized) and Item like {api.fetch.music}'s.

{traversejson:songs.0.title|{music.identify}}
→The title of the song a mix is on.
  • Only NotSoAI can use this. In a user's tag (or a tag NotSoAI calls with {tag}) the function is left as plain text. It is also left as plain text when run from a button or menu NotSoAI made, since someone else could press it. When NotSoAI's prompt had someone else's text in it (another person's message it replied to, a link, a file that isn't the user's own upload, or the url option, earlier in the conversation too), or in code that only exists while running, like an {ai} reply or what {eval} and {evalsilent} run, it first asks the person with Allow and Cancel buttons (up to 3 times per message) and is left as plain text if they cancel or don't answer within a minute.
  • It only knows NotSoBot's own music. A song playing from someone else needs music listen.
  • Counts against the network request limit.

{music.play}

Queues a song in the person's voice channel, like music play. Only NotSoAI can use this.

{music.play:query}

Searches for the song (or takes a Spotify, Deezer, TIDAL, Apple Music or YouTube Music track link, or a link to a file) and queues it in the voice channel the person is in, joining it if the bot isn't playing yet. A search takes the best result the server's queue rules allow instead of asking to pick one. Album and playlist links need a premium server.

Outputs JSON: {added: number, collection: string | null, joined: boolean, not_added: number, track: Item}, where Item is shaped like {api.fetch.music}'s and track.position 1 means it's playing now. added and not_added count an album's or playlist's tracks.

query
What to search for, or a track, album, playlist or file link.
{traversejson:track.position|{music.play:lorde royals}}
→3
  • Only NotSoAI can use this. In a user's tag (or a tag NotSoAI calls with {tag}) the function is left as plain text. It is also left as plain text when run from a button or menu NotSoAI made, since someone else could press it. When NotSoAI's prompt had someone else's text in it (another person's message it replied to, a link, a file that isn't the user's own upload, or the url option, earlier in the conversation too), or in code that only exists while running, like an {ai} reply or what {eval} and {evalsilent} run, it first asks the person with Allow and Cancel buttons (up to 3 times per message) and is left as plain text if they cancel or don't answer within a minute.
  • The server's queue rules, queue limit and fair queue apply like they do for music play.
  • NotSoAI can queue music at most 3 times per message.
  • An empty argument outputs nothing.
  • Counts against the network request limit.

{request}

Makes an HTTP request and outputs the response as JSON.

{request:json}

Takes a JSON object with the request options:

method (required): GET, POST, PUT, PATCH, DELETE or HEAD (case-insensitive).

url (required): the URL to request.

headers: an object of header names to values.

query: an object of query string parameters.

json: a JSON body (object or array). Only used for POST, PUT and PATCH.

data: a form body, as a flat object whose values are strings, numbers or booleans. Only used for POST, PUT and PATCH, and cannot be combined with json.

The output is a JSON string like {"cookies": {...}, "data": ..., "data_is_bytes": false, "headers": {...}, "status": 200, "url": "..."}, where data is the response body: the parsed JSON if the body is JSON, otherwise its text. data_is_bytes is currently always false.

json
The request options object described above.
{request:{"method": "GET", "url": "https://httpbin.org/get", "query": {"q": "cats"}}}
→{"cookies":{},"data":...,"data_is_bytes":false,"headers":{...},"status":200,"url":"https://httpbin.org/get?q=cats"}
{request:{"method": "POST", "url": "https://httpbin.org/post", "json": {"text": {jsonify:{args}}}}}
→Sends the arguments as a JSON body and outputs the response
  • Counts against the network request limit.
  • Use {jsonify} to safely put text inside the JSON options.
  • Invalid options give a specific error, e.g. "Request method is invalid.", "Request url is invalid." or "Request cannot have both json and data.". Options that are not valid JSON are also an error.
  • If the request fails, the tag errors, including any details the request service gives.
  • The URL is parsed like other media URLs, so a user mention or ID becomes their avatar URL and a custom emoji becomes its image URL.

Output

Embeds, buttons, pages, and files attached to the reply.

{componentjson}

Adds a message component (buttons, select menus, containers, etc.) from JSON.

{componentjson:json}

The argument is a Discord component object in JSON, optionally wrapped in a code block. Tagscript inside it is parsed first, then the JSON is read and added to the message. Supported types include action rows, buttons, select menus, containers, sections, text displays, thumbnails, media galleries, files and separators.

Buttons need a label or a url (a URL makes it a link button), and can have a run string of tagscript to execute when pressed.

json
A single component object as JSON.
{componentjson:{"type": 1, "components": [{"type": 2, "label": "Click me", "run": "You clicked it!"}]}}
→Adds an action row with one button.
{componentjson:{"type": 2, "label": "Docs", "url": "https://notsobot.com"}}
→Adds a link button.
  • Invalid JSON, or JSON that is not an object, throws an error.
  • {newline} inside a JSON string becomes a real line break.
  • Up to 5 action rows or 25 loose buttons per message, and you cannot mix action rows with loose buttons.
  • Action rows hold 1–5 components; containers hold 1–40.
  • Buttons and select menu options take an emoji: one unicode emoji, or a custom emoji as {"id": "...", "name": "..."}. A button can have just an emoji.
  • NotSoAI's replies can use ai instead of run: pressing the button (or picking from the select menu, {values} is what was picked) sends that text to NotSoAI as your next message in the conversation. ai_input on a button opens a text box and sends what you type. Only the person who asked can press them, a press turns off the message's other components unless "once": false, and they work for ten minutes. Tags can't use them.

{componentsontimeout}

Sets tagscript that runs when the message's components expire.

{componentsontimeout:tagscript}

The argument is stored as-is (it is not parsed right away) and is run once the components time out.

tagscript
The tagscript to run on timeout.
{componentsontimeout:Too slow! The buttons expired.}
→Shows that text once the buttons stop working.
  • Only one timeout script is kept; using this again replaces the previous one.
  • An empty argument leaves the function as-is in the output.

{embedjson}

Adds an embed to the tag's response.

{embedjson:json}

Takes a Discord embed object as JSON, e.g. title, description, url, color (a number), timestamp, fields (objects with name, value and inline), author, footer, image and thumbnail (objects with a url).

json
An embed object as JSON. Functions inside it are evaluated first.
{embedjson:{"title": "Hello {user}!", "description": "Welcome to {guild}", "color": 16750592}}
→Adds an orange embed greeting the user.
{embedjson:{"image": {"url": "{avatar}"}}}
→Adds an embed showing your avatar.
  • If the JSON is invalid, or the embed has no text and no image/thumbnail/video url, the function is left as plain text.
  • {newline} inside a JSON string becomes a real line break.
  • A tag can have at most 10 embeds, going over causes an error.

{pagejson}

Adds one or more pages to the reply, shown with page buttons.

{pagejson:json}

Takes a JSON object describing one page, or an array of them. Each page can have:

content: a string of text.

embed: a single embed object (it must have some content, an image, a thumbnail, or a video).

files: an array of attachment://filename strings, pointing at files the tag attached.

components: an array of Components V2 layout components (action rows, containers, files, media galleries, sections, separators, text displays).

Every page needs at least one of these.

json
A page object, or an array of page objects.
{pagejson:[{"content": "Page one"}, {"content": "Page two"}]}
→Two pages you can flip between
{pagejson:{"embed": {"title": "Hello", "description": "An embed page"}}}
→Adds a page with an embed
{pagejson:{"components": [{"type": 17, "components": [{"type": 10, "content": "Inside a container"}]}]}}
→Adds a page with a container holding some text
  • Invalid JSON, a page that is not an object, an empty embed, or a page with nothing usable is an error.
  • {newline} inside a JSON string becomes a real line break.
  • Page components cannot be interactive: buttons must be link buttons and select menus are not allowed. Buttons must be inside action rows or sections.
  • Each page can have at most 33 components (counting nested ones).
  • A tag can have at most 1000 pages.

{setfilename}

Rename a file the tag is attaching.

{setfilename:file number|name?|extension?}

Changes the filename (and optionally the extension) of one of the files already attached by the tag, such as one added by {attach}, {imagine} or {mediascript}.

file number
Which attached file to rename, starting at 1.
nameoptional
The new name, without the extension. Leave empty to keep the old name.
extensionoptional
The new extension, without the dot. If left out entirely, the old extension is kept; if given but empty, the file ends up with no extension.
{setfilename:1|myfile}
→Renames the first file to myfile, keeping its extension (e.g. myfile.png)
{setfilename:1|notes|txt}
→Renames the first file to notes.txt
{setfilename:1||gif}
→Keeps the name but changes the extension to .gif
  • Errors if there is no attached file with that number.
  • Left as plain text if there is no | or the file number is not a number.
  • This only renames the file; it does not convert it.

JSON

Discord objects as JSON, and reading JSON.

{json.channel}

channeljson

Outputs a channel as a JSON object.

{json.channel:channel?}

The object uses Discord's field names, such as id, name, type, guild_id, parent_id, position, nsfw, permission_overwrites and (for text channels) topic.

channeloptional
Optional. A channel in this server, by mention, ID or name. Defaults to the current channel.
{traversejson:name|{json.channel}}
→general
{json.channel:560595518129045504}
→{"id":"560595518129045504","name":"general","type":0,...}
  • If no channel matches, nothing is output.
  • If the current channel is not cached it is fetched, which counts as a network request.

{json.guild}

Outputs the current server as a JSON object.

{json.guild}

Includes the server's details (such as id, name, owner_id), along with its members and a presences list built from the members' presences.

{traversejson:name|{json.guild}}
→NotSoServer
  • In very large servers (over 10,000 members) only you, the bot and members in voice channels are included in members.
  • In DMs nothing is output.

{json.member}

Outputs a server member as a JSON object.

{json.member:user?}

The object uses Discord's field names, such as user, nick, joined_at, premium_since, roles (full role objects), hoisted_role, communication_disabled_until, avatar and permissions.

useroptional
Optional. A mention, user ID or name. Defaults to you.
{traversejson:nick|{json.member}}
→Your nickname
{json.member:@Cake}
→Cake's member object
  • Looking up another user counts as a network request.
  • If the user is not a member of this server (or you are in DMs), nothing is output.

{json.memberoruser}

Outputs a member as JSON, or a user if they are not in the server.

{json.memberoruser:user?}

Gives the same object as {json.member} when possible, and falls back to the user object from {json.user} otherwise (for example in DMs).

useroptional
Optional. A mention, user ID or name. Defaults to you.
{json.memberoruser}
→Your member object, or your user object in DMs
  • Looking up another user counts as a network request.
  • If nobody matches, nothing is output.

{json.message}

Outputs a message as a JSON object.

{json.message:messageId?}

The object uses Discord's field names, such as id, content, author, member, attachments, embeds, components, mentions, reactions, timestamp, edited_timestamp and referenced_message.

messageIdoptional
Optional. The ID of a message in the current channel. Defaults to the message that ran the tag.
{traversejson:content|{json.message}}
→The content of the message that ran the tag
{json.message:{messagelastid}}
→The last message in the channel as JSON
  • Only messages in the current channel can be fetched.
  • When an ID is given, you need View Channel and Read Message History in the channel, and so does the bot, otherwise an error is thrown.
  • Fetching a message that is not cached counts as a network request. If it cannot be found, nothing is output.
  • With no ID, nothing is output when the tag was run with a slash command.

{json.messagereply}

Outputs the message being replied to as a JSON object.

{json.messagereply}

Same shape as {json.message}, but for the message the tag's message replied to.

{traversejson:author.username|{json.messagereply}}
→The username of whoever wrote the replied-to message
  • Outputs nothing if the message is not a reply, or when the tag was run with a slash command.

{json.role}

Outputs a server role as a JSON object.

{json.role:role?}

The object uses Discord's field names, such as id, name, color, colors, position, permissions, hoist, mentionable, managed, icon and unicode_emoji, plus member_count, how many of the server's cached members have the role.

roleoptional
Optional. A role mention, ID or name. Defaults to your highest role.
{traversejson:name|{json.role}}
→The name of your highest role
{traversejson:member_count|{json.role:moderator}}
→How many members have the Moderator role
  • Names match the start of a role's name first, then anywhere in it.
  • member_count only counts cached members, so it can be lower than the real count in big servers.
  • Outputs nothing outside of a server, or if no role matches.

{json.user}

userjson

Outputs a user as a JSON object.

{json.user:user?}

The object uses Discord's field names, such as id, username, global_name, discriminator, avatar, bot, system and public_flags.

useroptional
Optional. A mention, user ID or name. Defaults to you.
{traversejson:global_name|{json.user}}
→Your display name
{json.user:@Cake}
→{"avatar":"...","bot":false,"id":"...","username":"cake",...}
  • Looking up another user counts as a network request.
  • If nobody matches, nothing is output.

{jsonify}

Turns text into a JSON string, with quotes and escaping.

{jsonify:text}

Wraps the text in double quotes and escapes quotes, backslashes and new lines, so it can be dropped into JSON safely (for example in {request} or {pagejson}).

text
The text to convert.
{jsonify:He said "hi"}
→"He said \"hi\""
{pagejson:{"content": {jsonify:{args}}}}
→A page containing the arguments, safely escaped

{traversejson}

Pulls a value out of JSON using a path like cake[0].test.

{traversejson:path|json}

The path is split into keys:

a.b goes into key a, then key b.

a[0] goes into key a, then index 0 of the array.

a["some.key"] or a['some.key'] uses a quoted key, so dots and brackets inside it are kept (use \ to escape a quote).

If the value found is an object or array it is output as JSON, otherwise it's output as-is.

path
Where to look, e.g. data.items[2].name.
json
The JSON text to search through. Everything after the first |.
{traversejson:cake[0].test|{"cake":[{"test":"a"}]}}
→a
{traversejson:cake|{"cake":[1,2,3]}}
→[1,2,3]
{traversejson:["a.b"]|{"a.b":5}}
→5
  • If the path doesn't exist, nothing is output.
  • Invalid JSON, an empty path, or a missing | makes the function fail.

Tags

Run other tags and read tag info.

{api.fetch.tags}

Outputs the user's own tags in this server as JSON. Only NotSoAI can use this.

{api.fetch.tags}

Outputs an object like {"count": number, "tags": [...]} with their newest 50 tags in the current server (or DM). Each tag has name, uses, locked, alias_of (the tag an alias points to, or null) and content, the first 100 characters of it (empty for an alias). count is every tag they have here.

{traversejson:count|{api.fetch.tags}}
→How many tags the user has in this server.
  • Only NotSoAI can use this. In a user's tag (or a tag NotSoAI calls with {tag}) the function is left as plain text. It is also left as plain text when run from a button or menu NotSoAI made, since someone else could press it. When NotSoAI's prompt had someone else's text in it (another person's message it replied to, a link, a file that isn't the user's own upload, or the url option, earlier in the conversation too), or in code that only exists while running, like an {ai} reply or what {eval} and {evalsilent} run, it first asks the person with Allow and Cancel buttons (up to 3 times per message) and is left as plain text if they cancel or don't answer within a minute.
  • Counts against the network request limit.

{ismaintag}

Outputs true if this is the tag that was run directly, or false if it was called from another tag with {tag}.

{ismaintag}
{if:{ismaintag}|=|true|then:Run directly!|else:Called from another tag.}
→Run directly!

{limits}

Outputs the time limits this run is under as JSON, which depend on premium.

{limits}

The limits come from the tier of whoever ran the tag, or the server's premium when they have none. All times are in milliseconds. tag_ms is how long the whole tag can run and tag_left_ms how much of that is left. mediascript_ms is how long one {mediascript} can take, links it downloads included, and is the most its timeleft variable starts at.

{limits}
→{"tier":"premium","tag_ms":70000,"tag_left_ms":69987,"mediascript_ms":60000}
{traversejson:{limits}|mediascript_ms}
→60000
  • tier is one of free, premium_server, premium, premium_plus or premium_max.
  • Verified directory tags get more tag time than a free user, that only shows in tag_ms.

{tag}

Runs another tag by its ID and inserts its output.

{tag:tag_id|arguments?}

The first part is the ID of the tag to run, everything after the first | is passed to that tag as its arguments (what {args} returns inside it).

The called tag runs as if it were the current tag, so functions like {tagid} and {tagname} refer to it while it runs, and its output (text, embeds, files, etc.) is merged into the current tag's output. Variables you set in your tag are not shared with the called tag and the called tag's variables do not leak back, unless the tag calls itself, in which case all variables are shared. Usage limits (network requests, tag executions, etc.) are shared between the two.

tag_id
The ID of the tag to run (not its name).
argumentsoptional
Text passed to the called tag as its arguments. Defaults to nothing.
{tag:123456789012345678}
→The output of tag 123456789012345678, run with no arguments
{tag:123456789012345678|hello world}
→The output of that tag, with {args} being "hello world" inside it
  • The tag must be on the tag directory, or belong to the same server (or the tag owner's DMs). Otherwise it errors.
  • Errors if the ID is missing or is not a valid ID.
  • Counts toward the tag execution limit (default 2 per run) and counts as a network request.
  • Calling the tag also increases its usage count.
  • It is ignored (outputs nothing) when used inside code/component JSON child parsing.
  • The called tag always counts as a user's tag, even when NotSoAI calls it, so {isfromai} is false inside it and NotSoAI-only functions do not work there.

{tag.create}

Saves a new tag for the person who asked NotSoAI. Only NotSoAI can use this.

{tag.create:name|content}

Creates a tag owned by the person who asked NotSoAI, in the current server (or DM), and outputs its name. The content is parsed like any other argument, so wrap TagScript in {ignore} to save the code itself instead of its output.

name
The new tag's name, up to 64 characters. It is saved in lowercase.
content
The tag's content, up to 2000 characters. Everything after the first | is used.
{tag.create:greet|{ignore:hi {user}!}}
→greet, and running tag greet says hi to whoever runs it
  • Only NotSoAI can use this, and only in its own reply: in a user's tag, or a button NotSoAI made, the function is left as plain text. When NotSoAI's prompt had someone else's text in it (another person's message it replied to, a link, a file that isn't the user's own upload, or the url option, earlier in the conversation too), or in code that only exists while running, like an {ai} reply or what {eval} and {evalsilent} run, it first asks the person with Allow and Cancel buttons (up to 3 times per message) and is left as plain text if they cancel or don't answer within a minute.
  • Only makes new tags. Errors if a tag with that name already exists in the server, even one of your own ({tag.edit} changes those).
  • NotSoAI can only create one tag per message.
  • Counts against the API manipulation limit (1 per run by default) and the network request limit.

{tag.delete}

Deletes one of the user's own tags. Only NotSoAI can use this.

{tag.delete:name}

Deletes a tag owned by the person who asked NotSoAI, in the current server (or DM), and outputs true.

name
The tag's name.
{tag.delete:greet}
→true
  • Only NotSoAI can use this. In a user's tag (or a tag NotSoAI calls with {tag}) the function is left as plain text. It is also left as plain text when run from a button or menu NotSoAI made, since someone else could press it. When NotSoAI's prompt had someone else's text in it (another person's message it replied to, a link, a file that isn't the user's own upload, or the url option, earlier in the conversation too), or in code that only exists while running, like an {ai} reply or what {eval} and {evalsilent} run, it first asks the person with Allow and Cancel buttons (up to 3 times per message) and is left as plain text if they cancel or don't answer within a minute.
  • Only works on the user's own tags in the current server (or DM). Throws an error for someone else's tag (even for moderators, who can still use tag remove), a locked tag, or a name with no tag here.
  • NotSoAI can edit or delete at most 3 tags per message; another one throws an error.
  • Counts against the network request limit.
  • An empty name outputs nothing.
  • Asks the person to confirm with Allow and Cancel buttons first, even when nobody else's text was in the prompt. It is left as plain text if they cancel or don't answer within a minute.

{tag.edit}

Replaces the content of one of the user's own tags. Only NotSoAI can use this.

{tag.edit:name|content}

Replaces the content of a tag owned by the person who asked NotSoAI, in the current server (or DM), and outputs its name. The content is parsed like any other argument, so wrap TagScript in {ignore} to save the code itself instead of its output.

name
The tag's name.
content
The tag's new content, up to 2000 characters. It replaces the whole tag.
{tag.edit:greet|{ignore:hey {user}, welcome back!}}
→greet
  • Only NotSoAI can use this. In a user's tag (or a tag NotSoAI calls with {tag}) the function is left as plain text. It is also left as plain text when run from a button or menu NotSoAI made, since someone else could press it. When NotSoAI's prompt had someone else's text in it (another person's message it replied to, a link, a file that isn't the user's own upload, or the url option, earlier in the conversation too), or in code that only exists while running, like an {ai} reply or what {eval} and {evalsilent} run, it first asks the person with Allow and Cancel buttons (up to 3 times per message) and is left as plain text if they cancel or don't answer within a minute.
  • Only works on the user's own tags in the current server (or DM). Throws an error for someone else's tag (even for moderators, who can still use tag remove), a locked tag, or a name with no tag here.
  • NotSoAI can edit or delete at most 3 tags per message; another one throws an error.
  • Counts against the network request limit.
  • Throws an error for an alias, edit the tag it points to instead.

{tagcontent}

Outputs the raw, unparsed content of the current tag.

{tagcontent}

If the tag is an alias of another tag, the original tag's content is output.

{code:{tagcontent}}
→Shows the tag's own source in a code block
  • Outputs nothing if not run from a saved tag.

{tagid}

Outputs the ID of the current tag.

{tagid}
{tagid}
→123456789012345678
  • Outputs nothing if not run from a saved tag. Inside a tag called with {tag}, this is the called tag's ID.

{tagname}

Outputs the name of the current tag.

{tagname}
You are using the "{tagname}" tag!
→You are using the "cookie" tag!
  • Outputs nothing if not run from a saved tag. Inside a tag called with {tag}, this is the called tag's name.

{tagownerid}

Outputs the user ID of the current tag's owner.

{tagownerid}
{tagownerid}
→300505364032389122
<@{tagownerid}> made this tag
→Mentions the tag owner
  • Outputs nothing if not run from a saved tag.

Time

Timestamps and dates.

{unix}

Outputs a Unix timestamp in milliseconds, either now or for a time you describe.

{unix:time?}

With no argument it outputs the current time. With an argument, it reads natural language like "tomorrow at 5pm" or "in 2 hours", relative to when the message was sent and using the user's timezone.

timeoptional
A time in plain words, e.g. "in 3 days" or "next friday at noon".
{unix}
→1760270400000
{unix:in 1 hour}
→The timestamp (ms) one hour from now
  • If the time can't be understood, nothing is output.

{unixs}

Outputs a Unix timestamp in seconds, either now or for a time you describe.

{unixs:time?}

Same as {unix}, but in seconds (rounded down), which is what Discord's <t:...> timestamps use.

timeoptional
A time in plain words, e.g. "tomorrow at 9am".
{unixs}
→1760270400
Event starts <t:{unixs:saturday at 8pm}:R>
→Event starts in 5 days (rendered by Discord)
  • If the time can't be understood, nothing is output.

{unixsnowflake}

Outputs the creation time (Unix milliseconds) of a Discord ID.

{unixsnowflake:id}

Every Discord ID (users, messages, channels, servers, etc.) has its creation time built in. This pulls it out.

id
Any Discord ID.
{unixsnowflake:{id}}
→When your account was created, in Unix milliseconds
  • Outputs nothing with an empty argument.
  • If the argument is not a number, the function is left in the output as plain text.

Miscellaneous

Everything else.

{eval}

Evaluates its argument a second time.

{eval:code}

The argument is evaluated like any other function argument, then the result is evaluated again as tagscript. This lets you build code out of text, for example with {bracketleft} and {bracketright}.

code
The text to evaluate.
{eval:{bracketleft}user{bracketright}}
→Your username
{set:code|{ignore:{range:1|10}}}{eval:{get:code}}
→A random number from 1 to 10

{evalsilent}

Evaluates its argument and swallows any error.

{evalsilent:code}

Unlike {eval}, the argument is only evaluated once. If anything inside throws an error, the output of the whole block is dropped and the tag keeps going.

code
The tagscript to run.
{evalsilent:{getfilename:5}}Done
→Done (even if there is no 5th file)
  • An {exit} or {exitsilent} inside is not swallowed, it still stops the whole tag.

{ignore}

Outputs its content as-is, without running any functions inside it.

{ignore:text}

Handy for showing tagscript code literally, or for passing code somewhere that will run it later (like a component run script).

text
The text to output untouched. Curly brackets inside must still be balanced.
{ignore:{user}}
→{user}
Type {ignore:{args}} to see your arguments
→Type {args} to see your arguments

{isfromai}

Outputs true if the code was written by NotSoAI, otherwise false.

{isfromai}

True when the code running is NotSoAI's response (from the AI command, or an {ai} reply that gets run as code), and false in a user's tag, including a tag NotSoAI calls with {tag}. This is the same check the NotSoAI-only functions use.

{isfromai}
→false (in a user's tag)

{isfromcomponent}

Outputs true if the code is running because of a component (button/select menu use or a component timeout), otherwise false.

{isfromcomponent}
{if:{isfromcomponent}|=|true|then:Thanks for clicking!|else:Click the button below.}
→Click the button below. (when first run)

{note}

A comment. Outputs nothing and runs nothing inside it.

{note:text}
text
Anything you want, it is ignored completely.
{note:this part greets the user}Hello {user}!
→Hello Cake!

{nsfw}

Stops the tag with an error unless it is being used somewhere NSFW content is allowed.

{nsfw}

Put this at the start of a tag that should only be used in NSFW channels. It outputs nothing when NSFW content is allowed.

NSFW is allowed in DMs with the bot, in age-restricted channels, and in servers whose explicit content filter does not apply to the user. It is not allowed when the bot is used as a user-installed app outside of a server it is in.

{nsfw}Spicy content here
→Errors in a normal channel, shows the text in an NSFW channel

{prefix}

Outputs the command prefix that was used to run the tag.

{prefix}

For slash commands and other interactions this is always /.

Try {prefix}help
→Try .help (if the tag was run with the . prefix)

{settings}

Changes how the tag behaves for the rest of the run.

{settings:SETTING|value}

Takes exactly two parts: the setting name (case-insensitive) and its value. Spaces around either part are ignored, and an empty value clears the setting. Settings only last for the current run of the tag.

AI_MODEL: the AI model used by the text generation functions (an invalid model errors and lists the valid ones).

AI_PERSONALITY: a personality prompt used by the text generation functions, instead of the user's or server's.

ALLOW_COMPONENT_EXECUTIONS_FROM_EVERYONE: true lets anyone use the tag's buttons and menus, not just the person who ran the tag. false turns it back off.

DISPLAY_MEDIA_AS_NATIVE: by default, a reply that is only one file (or only one nsb.gg link), with no text, embeds or buttons, is shown like a media command's reply. true sends it as a plain Discord attachment or link instead. false turns it back off.

MEDIA_IV_FALLBACK: when an image function (such as {iv} or {image}) cannot find media from its argument, it runs this function with the same argument instead and uses the URL it gives back. One of MEDIA_IMAGE_IMAGINE (or imagine/imagineurl, generates an image and uses its temporary URL), SEARCH_DUCK_DUCK_GO_IMAGES (or SEARCH_DUCKDUCKGO_IMAGES or a search.duckduckgo.images name) or SEARCH_GOOGLE_IMAGES (or a search.google.images name).

MEDIA_AV_FALLBACK: the same, for audio/video functions such as {transcribe}. Only SEARCH_YOUTUBE (or a search.youtube name) is allowed.

ML_IMAGINE_DO_NOT_ERROR: a true/false value. When true, image generation is asked not to error.

ML_IMAGINE_MODEL: the image generation model, currently only FLUX_KLEIN (case-insensitive).

SETTING
The setting name, from the list above.
value
The new value for the setting.
{settings:MEDIA_IV_FALLBACK|search.google.images}{iv:{args}}
→Uses the arguments as media, or searches Google Images for them if they are not media
{settings:ML_IMAGINE_MODEL|FLUX_KLEIN}{imagine:a cat in a hat}
→Generates the image with Flux Klein
{settings:ALLOW_COMPONENT_EXECUTIONS_FROM_EVERYONE|true}
→Lets everyone press the tag's buttons
{settings:MEDIA_IV_FALLBACK|MEDIA_IMAGE_IMAGINE}{edit:make it snow}
→Edits the last image, or a freshly generated one if there is none
{settings:ML_IMAGINE_MODEL|}
→Clears the model setting again
  • Outputs nothing on success.
  • If there are not exactly two parts, or the setting name is unknown, the function is left in the output as plain text.
  • An unrecognised value for MEDIA_IV_FALLBACK or MEDIA_AV_FALLBACK is silently ignored. For the true/false settings, true, yes, y and + enable them; anything else (including false) clears them.