diff --git a/config/config.example.exs b/config/config.example.exs index ddea0e3..1e29cd7 100644 --- a/config/config.example.exs +++ b/config/config.example.exs @@ -8,4 +8,5 @@ config :nostrum, :guild_messages, :message_content, :guild_message_reactions - ] + ], + prefix: "haha " diff --git a/lib/events/messages.ex b/lib/events/messages.ex index a0007ee..846544b 100644 --- a/lib/events/messages.ex +++ b/lib/events/messages.ex @@ -6,14 +6,15 @@ defmodule HahaYes.Events.MessagesConsumer do use Nostrum.Consumer def handle_event({:MESSAGE_CREATE, msg, ws_state}) when msg.author.bot != true do - if String.starts_with?(msg.content, "h3h3 ") do + prefix = Application.get_env(:nostrum, :prefix) + if String.starts_with?(msg.content, prefix) do msg.content - |> String.replace("h3h3 ", "") + |> String.replace(prefix, "") |> String.split(" ") |> Enum.at(0) |> String.downcase() |> String.capitalize() - |> then(& apply(String.to_atom("#{HahaYes.Commands}.#{&1}"), :execute, [msg, ws_state, String.replace(msg.content, "h3h3 download ", "")])) + |> then(& apply(String.to_atom("#{HahaYes.Commands}.#{&1}"), :execute, [msg, ws_state, String.split(String.replace(msg.content, "h3h3 download ", ""))])) end end end