Skip to content

Reactions

A command can react to reactions. Send a message with some reactions on it, and when someone reacts with one of them, the same command runs again, with the person who reacted. The reaction works like a button: it can change the message, give or take a role, answer in the channel and more.

{{ if eq .Trigger "command" }}
{{ sendMessage nil (complexMessage
"embed" (cembed "description" "React with 🦋 to claim this")
"reactions" (cslice "🦋" "🎀")) }}
{{ return }}{{ end }}
{{/* From here on, someone reacted */}}
{{ if eq .Reaction.Emoji "🦋" }}
{{ updateMessage (cembed "description" (print "Claimed by " .User.Username)) }}
{{ removeReaction }}
{{ end }}
  • "reactions" in complexMessage is a list of up to 5 emojis. Petto puts them on the message and remembers it for one week.
  • .Trigger is "reaction" when someone reacted. .Reaction.Emoji is the emoji the way you wrote it in the list, and .Reaction.Added is true.
  • .User and .Member are the person who reacted. .Message is the message they reacted to, with its embeds.
  • Only reactions from people count, never from bots, and only the emojis in the list.
  • For a custom emoji write it as Discord does, <:name:123456789012345678>, in the list and in the check.
Function In a reaction
updateMessage message Changes the message that was reacted to. What you do not give stays. It only works on a message Petto sent
respond message Sends a message in the channel of the reaction. It cannot be private, a reaction has no private answer
removeReaction Takes the reaction of that person away, so it can be used again
addRole, removeRole Give or take a role of the person who reacted, with the same checks
sendMessage, sendDM, addReaction, dbSet… As always

Printing text sends it in the channel, like respond.

  • Only the messages of the command that sent them with "reactions" answer. A reaction to any other message does not run anything.
  • The reactions only work in a message sent with sendMessage, not in a direct message or an answer to a click.
  • Using the same reaction twice in a very short time is ignored.
  • The keys of stored data that start with rx: are reserved: Petto uses them to remember these messages. They do not count towards the 500 values of a server.
  • Each run has the same limits as a command.

The claim template is a request card: !claim a cake sends it with 🦋 and 🎀. 🦋 marks it as claimed by the person who reacted, and 🎀 only counts if it is the person who asked. Install it with !customcommand template claim and read its code with !customcommand codeshow claim.