Skip to content

Commit

Permalink
ignore bots
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrabbers committed Feb 21, 2023
1 parent 3b5999f commit b7dfc0e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ config :logger,

config :ffc_ex,
prefix: if(Mix.env() == :prod, do: "ffc:", else: "ffd:"),
color: if(Mix.env() == :prod, do: 0x4251F5, else: 0xFFFFFF)
color: if(Mix.env() == :prod, do: 0xFF3F3F, else: 0x4251F5)

config :nostrum,
gateway_intents: [
Expand Down
12 changes: 7 additions & 5 deletions lib/ffc_ex/base_consumer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ defmodule FfcEx.BaseConsumer do
use Nostrum.Consumer

alias FfcEx.{Game, GameCmdParser, GameLobbies, GameRegistry, PlayerRouter}
alias Nostrum.{Api, Struct.Embed, Struct.User, Util}
alias Nostrum.{Api, Struct.Embed, Struct.User, Struct.Message, Util}

require Logger

Expand All @@ -11,7 +11,7 @@ defmodule FfcEx.BaseConsumer do
end

@impl true
def handle_event({:MESSAGE_CREATE, msg, _ws_state}) do
def handle_event({:MESSAGE_CREATE, %Message{author: %User{bot: nil}} = msg, _ws_state}) do
prefix = Application.fetch_env!(:ffc_ex, :prefix)

case msg.guild_id do
Expand All @@ -35,6 +35,7 @@ defmodule FfcEx.BaseConsumer do
if int != nil do
PlayerRouter.set_for(msg.author.id, int)
end

if res and match?({:chat, _}, cmd) do
Api.create_reaction!(msg.channel_id, msg.id, "✅")
end
Expand Down Expand Up @@ -78,7 +79,7 @@ defmodule FfcEx.BaseConsumer do
[**Click here to view game instructions.**](https://vrabbers.github.io/ffc_ex/index.html)
""",
color: Application.fetch_env!(:ffc_ex, :color),
thumbnail: %Embed.Thumbnail{url: User.avatar_url(Api.get_current_user!())}
thumbnail: %Embed.Thumbnail{url: User.avatar_url(Api.get_current_user!(), "png")}
}

Api.create_message!(msg.channel_id, embeds: [embed])
Expand Down Expand Up @@ -120,7 +121,7 @@ defmodule FfcEx.BaseConsumer do
""",
timestamp: DateTime.to_iso8601(DateTime.utc_now()),
color: Application.fetch_env!(:ffc_ex, :color),
thumbnail: %Embed.Thumbnail{url: User.avatar_url(Api.get_current_user!())}
thumbnail: %Embed.Thumbnail{url: User.avatar_url(Api.get_current_user!(), "png")}
}

Api.edit_message(message, content: "", embed: embed)
Expand All @@ -134,7 +135,8 @@ defmodule FfcEx.BaseConsumer do
end

defp join(msg, args) do
house_rules = args |> Enum.map(&house_rules/1) |> Enum.filter(& &1 != nil) |> Enum.uniq()
house_rules = args |> Enum.map(&house_rules/1) |> Enum.filter(&(&1 != nil)) |> Enum.uniq()

case GameLobbies.join(msg.channel_id, msg.author.id, house_rules) do
{:new, id, timeout} ->
prefix = Application.fetch_env!(:ffc_ex, :prefix)
Expand Down

0 comments on commit b7dfc0e

Please sign in to comment.