2024-10-12 17:06:08 +02:00
|
|
|
defmodule HahaYes.Events.MessagesConsumer do
|
|
|
|
@moduledoc """
|
|
|
|
Parse messages to execute commands
|
|
|
|
"""
|
|
|
|
|
|
|
|
use Nostrum.Consumer
|
|
|
|
|
2024-10-12 17:57:24 +02:00
|
|
|
def handle_event({:MESSAGE_CREATE, msg, ws_state}) when msg.author.bot != true do
|
2024-10-12 17:06:08 +02:00
|
|
|
if String.starts_with?(msg.content, "h3h3 ") do
|
|
|
|
msg.content
|
|
|
|
|> String.replace("h3h3 ", "")
|
|
|
|
|> String.split(" ")
|
|
|
|
|> Enum.at(0)
|
|
|
|
|> String.downcase()
|
|
|
|
|> String.capitalize()
|
2024-10-12 17:58:50 +02:00
|
|
|
|> then(& apply(String.to_atom("#{HahaYes.Commands}.#{&1}"), :execute, [msg, ws_state, String.replace(msg.content, "h3h3 download ", "")]))
|
2024-10-12 17:06:08 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|