Data
The code reads the data of the moment the command is used, with a dot. All of it is read-only: the code cannot change who the user is, only ask for actions (Actions).
| Name | What it is | Fields |
|---|---|---|
.User |
Who used the command | ID, Username, GlobalName, Mention, Avatar (a link), IsBot |
.Member |
The same person as a member of this server | Nick, DisplayName, RoleIDs (a list of IDs), JoinedAt (unix seconds) |
.Guild |
The server | ID, Name, MemberCount, Icon (a link) |
.Channel |
The channel where it was used | ID, Name, Mention |
.Message |
The message that used the command, or the message a button is on | ID, Content, Link, Embeds (a list of maps with Title, Description, Footer, Author, AuthorIcon, FooterIcon, Thumbnail, Image and Color) |
.Args |
What was written after the command, split by spaces | A list of text |
.RawArgs |
The same, as one text | |
.Cmd |
The name of the command that was used | |
.Prefix |
The prefix that started the command: the one of the server, or the command’s own prefix. Empty for the triggers startswith, exact and contains |
|
.Trigger |
Why the code is running: "command", "button" or "select" |
|
.Button |
When a button or a menu was used: a map with ID and Data. nil in a command |
ID, Data |
.Values |
When a menu was used, the chosen values. An empty list otherwise | A list of text |
Example:
{{ .User.Username }} wrote {{ len .Args }} words in {{ .Channel.Mention }}.Arguments
Section titled “Arguments”Every argument is text, even if it is a number. Math functions understand a text that holds a number, so
{{ add (index .Args 0) 1 }} works. To check how many were given, use len:
{{ if lt (len .Args) 1 }}Use: {{ .Prefix }}{{ .Cmd }} <something>{{ return }}{{ end }}Reading an argument that is not there, such as {{ index .Args 3 }} with two arguments, is a mistake.
.Member.RoleIDs is a list of role IDs. To know if the member has a role, use hasRole:
{{ if hasRole "223456789012345678" }}You have the role.{{ end }}