Skip to content

The Variable system

Casper1123 edited this page Oct 2, 2024 · 9 revisions

Welcome tot the wiki page on the variable system.
This page will be divided into the following segments:

  • Where to use variables
  • How to use variables
  • Regular variables
  • Command variables

Where to use variables

Variables are usable in many strings that the bot processes. The most important one of these is facts, but it also works on auto-replies, triggers, sayings, anything really. If you're interested in the code behind the processing, you can find it here.

How to use variables

Whenever you're adding a fact, variables are represented inside {}.
For what variables exist or how they work, see below.
To use a variable, take for example this following fact that you could enter into /admin preview [fact]:
Hello {user.name}! I hope you've been having {choice:"a nice","an awesome"} day.
Keep in mind that you can still use Markdown styling to for example link a channel: <#{channel.id}>

Regular variables

Regular variables are predefined pieces of data that you can access without any arguments.
*For bot hosters: Some information is only usable inside of servers. If something is **not globally* usable, it will have an * added to it

user

The user that triggered the response. This is either the caller of the command, or the sender of the message.

  • user.account the user's account name.
  • user.name the user's (nick)name.
  • user.id the user's account id.

guild

The server the command is ran in.

  • guild.id* the server's id.
  • guild.name* the server's name.

This also has the guild's owner. In case you ever need it. Don't be too annoying. - `guild.owner.account`* the account name of the server's owner. - `guild.owner.name`* the (nick)name of the server's owner. - `guild.owner.id`* the account id of the server's owner.

randomuser

A random account from the server's entire member list is selected for this iteration of the fact.
Using any of the randomuser variables will point towards the same person.

  • randomuser.account* the randomly picked user's account name.
  • randomuser.name* the randomly picked user's (nick)name.
  • randomuser.id* the randomly picked user's account id.

self

Refers to the bot (and it's account) itself.

  • self.name the bot's name.
  • self.id the bot's id.
  • self.nick* the bot's nickname.

General

More general-purpose variables.

  • enter Adds a newline. you can also just put \n inside of a fact which works the same.
  • total_facts the sum of the local and global fact counts.
  • global_facts the count of global facts.
  • local_facts the count of local facts.

Command variables

Expand this stub.

Clone this wiki locally