diff options
Diffstat (limited to 'lib/chessh/ssh/client')
-rw-r--r-- | lib/chessh/ssh/client/game/game.ex | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/chessh/ssh/client/game/game.ex b/lib/chessh/ssh/client/game/game.ex index 4a79d05..fc48d6f 100644 --- a/lib/chessh/ssh/client/game/game.ex +++ b/lib/chessh/ssh/client/game/game.ex @@ -77,7 +77,7 @@ defmodule Chessh.SSH.Client.Game do ) do {:allow, _count} -> # Starting a new game - {:ok, %Game{} = game} = + {:ok, %Game{id: game_id} = game} = Game.changeset( %Game{}, Map.merge( @@ -92,6 +92,12 @@ defmodule Chessh.SSH.Client.Game do ) |> Repo.insert() + GenServer.cast( + :discord_notifier, + {:schedule_notification, {:game_created, game_id}, + Application.get_env(:chessh, DiscordNotifications)[:game_created_notif_delay_ms]} + ) + init([ %State{ state @@ -403,6 +409,12 @@ defmodule Chessh.SSH.Client.Game do :syn.publish(:games, {:game, game_id}, {:new_move, attempted_move}) + GenServer.cast( + :discord_notifier, + {:schedule_notification, {:move_reminder, game_id}, + Application.get_env(:chessh, DiscordNotifications)[:game_move_notif_delay_ms]} + ) + _ -> nil end |