Use prefix from config
This commit is contained in:
parent
dec96177f5
commit
130e680739
2 changed files with 6 additions and 4 deletions
|
@ -8,4 +8,5 @@ config :nostrum,
|
||||||
:guild_messages,
|
:guild_messages,
|
||||||
:message_content,
|
:message_content,
|
||||||
:guild_message_reactions
|
:guild_message_reactions
|
||||||
]
|
],
|
||||||
|
prefix: "haha "
|
||||||
|
|
|
@ -6,14 +6,15 @@ defmodule HahaYes.Events.MessagesConsumer do
|
||||||
use Nostrum.Consumer
|
use Nostrum.Consumer
|
||||||
|
|
||||||
def handle_event({:MESSAGE_CREATE, msg, ws_state}) when msg.author.bot != true do
|
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
|
msg.content
|
||||||
|> String.replace("h3h3 ", "")
|
|> String.replace(prefix, "")
|
||||||
|> String.split(" ")
|
|> String.split(" ")
|
||||||
|> 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.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
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue