Alchemy.Cogs.def
You're seeing just the macro
def
, go back to Alchemy.Cogs module for more information.
Registers a new command, under the name of the function.
This macro modifies the function definition, to accept an extra
message
parameter, allowing the message that triggered the command to be passed,
as a t:Alchemy.Message/0
Examples
Cogs.def ping do
Cogs.say "pong"
end
In this case, "!ping" will trigger the command, unless another prefix has been set
with set_prefix/1
Cogs.def mimic, do: Cogs.say "Please send a word for me to echo"
Cogs.def mimic(word), do: Cogs.say word
Messages will be parsed, and arguments will be extracted, however, to deal with potentially missing arguments, pattern matching should be used. So, in this case, when a 2nd argument isn't given, an error message is sent back.