Described in doc what happens and replaced "apply" with "Module.concat"
This commit is contained in:
parent
95d6cc17b5
commit
c0dba0633b
1 changed files with 9 additions and 2 deletions
|
@ -1,6 +1,13 @@
|
||||||
defmodule HahaYes.Events.MessagesConsumer do
|
defmodule HahaYes.Events.MessagesConsumer do
|
||||||
@moduledoc """
|
@moduledoc """
|
||||||
Parse messages to execute commands
|
Parse messages to execute commands
|
||||||
|
|
||||||
|
1. Remove the prefix from the message.
|
||||||
|
2. Split the messages by spaces
|
||||||
|
3. Get the first result
|
||||||
|
4. Make it all lowercase
|
||||||
|
5. Make the first letter capitalized.
|
||||||
|
6. Call the execute function on the command.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
use Nostrum.Consumer
|
use Nostrum.Consumer
|
||||||
|
@ -14,7 +21,7 @@ defmodule HahaYes.Events.MessagesConsumer do
|
||||||
|> Enum.at(0)
|
|> Enum.at(0)
|
||||||
|> String.downcase()
|
|> String.downcase()
|
||||||
|> String.capitalize()
|
|> String.capitalize()
|
||||||
|> then(& apply(String.to_atom("#{HahaYes.Commands}.#{&1}"), :execute, [msg, ws_state, String.split(String.replace(msg.content, "h3h3 download ", ""))]))
|
|> then(& Module.concat(HahaYes.Commands, &1).execute(msg, ws_state, String.split(String.replace(msg.content, "h3h3 download ", ""))))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue