-
Notifications
You must be signed in to change notification settings - Fork 0
The Variable system
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
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.
Whenever you're adding a fact, variables are represented inside {}.
If you want to use
{or}without calling a variable, put a\before it (ex:\{\}) This also works for variable indicating characters in [command variables](https://github.com/Casper1123/Patrick-Bateman-Discord-Bot/wiki/The-Variable-system#command-variables). (for example, using a"inside of achoiceoption:{choice:"this has a " in it"}) For what variables exist or how they work, see below. <BR> To use a variable, take for example this following fact that you could enter into [/admin preview [fact]](https://github.com/Casper1123/Patrick-Bateman-Discord-Bot/wiki/Admin-commands#admin-preview-fact): <BR>Hello {user.name}! I hope you've been having {choice:"a nice","an awesome"} day.<BR> Keep in mind that you can still use [Markdown styling](https://gist.github.com/matthewzring/9f7bbfd102003963f9be7dbcf7d40e51) to for example link a channel:<#{channel.id}>`
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
The user that triggered the response. This is either the caller of the command, or the sender of the message.
-
user.accountthe user's account name. -
user.namethe user's (nick)name. -
user.idthe user's account id.
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.
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.
Refers to the bot (and it's account) itself.
-
self.namethe bot's name. -
self.idthe bot's id. -
self.nick* the bot's nickname.
More general-purpose variables.
-
enterAdds a newline. you can also just put \n inside of a fact which works the same. -
total_factsthe sum of the local and global fact counts. -
global_factsthe count of global facts. -
local_factsthe count of local facts.
Command variables (more commonly known as functions) take parameters to work properly. The type of parameters, and a couple examples, will be listed with their documentation.
rand:int,int takes a lower and an upper int (no space behind the comma , ) and generates a random number between those (inclusive)
ex:
{rand:1,5} is my lucky number.
choice:*str gives multiple options to select a random one from. The selection may contain variables.
Make sure to mark the ending of each option properly. The , in between is not mandatory, however using double quotations " is.
ex:
{choice:"option1","option2, it even has a variable: {rand:0,1}"}