Skip to content

Triggers and prefixes

A custom command starts with the prefix of the server, ! by default: !hello. A command can also have its own trigger, so people can start it in another way:

!customcommand trigger <name> <type> [text]
Type It starts when… Example Message that starts it
command The message starts with the prefix of Petto and the name. This is the default !hello
prefix The message starts with its own prefix and the name !customcommand trigger hello prefix ? ?hello
startswith The message starts with some words !customcommand trigger hi startswith hey bot hey bot, how are you?
exact The message is exactly some words !customcommand trigger gm exact good morning good morning
contains The message has some words inside !customcommand trigger pizza contains pizza I want pizza!

Without a type, !customcommand trigger <name> shows how the command starts now.

  • The case does not matter: Good Morning matches good morning.
  • A word is never cut in the middle: pizza matches I love pizza! but not pizzas or unpizza.
  • The arguments are what comes after the trigger. For ?hello big world, .Args is ["big", "world"]. For contains, .RawArgs is the whole message.
  • A command with a trigger of its own is not also started by the prefix of Petto. Setting command goes back to that.
  • A prefix is up to 5 characters without spaces, such as ?, >> or .. The other texts are up to 50 characters. A trigger cannot hold a mention.
  • If two commands could match the same message, the first one by name (alphabetical order) runs. Only one command runs for each message.
  • A prefix plus a name cannot be the name of a real command of Petto.

A server can have up to 25 commands with a trigger of their own. Each person can use each command once every 2 seconds, so a contains trigger cannot be used to flood a channel.

  • Use prefix to make commands that feel like their own bot: ?roll, >>shop.
  • Use exact for greetings and short phrases, and contains sparingly: it reads every message of the server.
  • The code can tell how it started: .Cmd is the name of the command and .Prefix is the prefix that started it (empty for startswith, exact and contains).