Described in doc what happens and replaced "apply" with "Module.concat"

This commit is contained in:
Loïc Bersier 2024-10-12 21:30:30 +02:00
parent 95d6cc17b5
commit c0dba0633b

View file

@ -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