R16 is a "trick bot". It saves snippets of code, which can then be recalled and executed on user-provided input.
As of the time of writing, there exists one frontend, for Discord. More are planned, so this manual is structured by frontend.
The bot is run by invoking its main.rkt file, and stores its configuration in a JSON file that is read on startup. See the -h output for precise details about command-line flags.
The configuration file must contain a top level object with the following keys and associated values:
storage: A string defining the folder in which to store the bot’s save data.
frontend: A nested object. Within that object, the module key must have a string value that is a module path as in dynamic-require which identifies the frontend to run. Frontends may require more specific configuration within this object, see the documentation of your chosen frontend for more details.
Tricks are stored as plain text, and invoked in a sandbox using racket/sandbox.
The following values are available in the sandbox’s namespace:
All symbols exported by threading, for convenience.
All items listed below.
Any items made available by the specific frontend, see the documentation of your chosen frontend for details.
string-args : string?
trick-name : string?
This frontend provides integration with the Discord chat service.
Commands to the bot are issued by prefixing Discord messages with a configurable prefix value. The rest of the message is then treated as a command. For more details, send the message <bot_prefix> help in your Discord server.
The frontend also has a configurable trick shorthand prefix. Messages of the form <trick_prefix>foo bar ... are equivalent to <bot_prefix> call foo bar ....
module must be the string "r16/frontends/discord".
bot_token must be a string containing your Discord bot token.
bot_prefix is a string specifying the bot’s trigger prefix. If not present, defaults to "!rkt ".
trick_prefix is a string specifying the bot’s shorthand prefix. If not present, defaults to "!!".
In additional to the bindings described above, the following items are available in the trick environment.
(delete-caller) → void?
message-contents : string?
A trick’s "trick-local storage" can be per-guild, per-channel, or per-user.
This will always return #f for the eval command.
This will always be a no-op when invoked from the eval command.
Returns #f if the message doesn’t have an indexth attachment, or if the attachment couldn’t be opened for any other reason.
attachment-count : natural?
reply-attachment-count : natural?