Skip to content

Actions

An action is something the code asks Petto to do in Discord. While the code runs nothing is done: the actions are collected, and Petto does them when the code ends, only the ones it is allowed to.

Every action function gives back nil, so it prints nothing. Writing the call in an action is enough:

{{ sendMessage nil "Hello" }}
Function What it asks Limit per run
sendMessage channel message Send a message. channel is the ID of a channel as text, or nil for the channel where the command was used 5
sendDM message Send a direct message to the person who used the command 2
addRole "roleID" Give a role to the person who used the command 5
removeRole "roleID" Take a role from that person 5
addReaction "emoji" React to the message that used the command 5
deleteTrigger Delete the message that used the command 1
respond message / respond message true Answer a button or a menu, in public or only to the person who used it (only works in a button or a menu) 1
updateMessage message Change the message a button is on (only works in a button or a menu) 1, and not together with respond

message is a text (at most 2000 characters), a cembed or a complexMessage (Embeds), which can also hold buttons and menus (Buttons and menus). A direct message cannot have buttons. An empty message is a mistake. If the code goes over a limit of actions, it stops with that mistake.

Besides the actions, the text printed by the code is sent as the answer of the command, in the channel where it was used. If you only want actions, print nothing.

  • Channels: a message to another channel is only sent if Petto can send there and the person who used the command can send there too, so a command can never be used to write where that person could not.
  • Roles: the role must exist, must not be a bot or integration role, must be below Petto’s highest role, and Petto needs the Manage Roles permission. A role with moderation or server permissions (Administrator, Manage Server, Manage Roles, Manage Channels, Manage Webhooks, Manage Messages, Ban, Kick, Timeout or Mention Everyone) is never given or taken by a command.
  • Pings: only the users and the roles the code mentions on purpose are pinged, and a role only if it is mentionable. @everyone and @here never ping.
  • Direct messages: if the person has them closed, it is skipped.
  • Delete: deleteTrigger only works if Petto can manage messages in that channel. It is done last, after the answer.
  • Cooldown: the same person can use the same command once every 2 seconds.

If an action is not done, Petto says why in a short message after the answer.