Skip to content

Commit

Permalink
fix lfm demoter from discord changes
Browse files Browse the repository at this point in the history
  • Loading branch information
THE9rtyt committed Dec 16, 2023
1 parent f0c2030 commit 980b6f4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/miata_bot_discord/listeners/looking_for_miata_listener.ex
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ defmodule MiataBotDiscord.LookingForMiataListener do
@impl Quarrel.Listener
def handle_guild_member_update(old, new, state) do
if state.config.looking_for_miata_role_id in (new.roles -- old.roles) do
Logger.info("refreshing timer for #{new.user.username}")
Logger.info("refreshing timer for #{new.user_id}")
timer = ensure_looking_for_miata_timer(state.guild, new)
refresh_looking_for_miata_timer(state.guild, timer)
end

if state.config.looking_for_miata_role_id in (old.roles -- new.roles) do
Logger.info("refreshing timer for #{new.user.username}")
Logger.info("refreshing timer for #{new.user_id}")
timer = ensure_looking_for_miata_timer(state.guild, new)
Repo.delete!(timer)
end
Expand All @@ -103,13 +103,13 @@ defmodule MiataBotDiscord.LookingForMiataListener do

def ensure_looking_for_miata_timer(guild, member) do
case Repo.get_by(LookingForMiataTimer,
discord_user_id: member.user.id,
discord_user_id: member.user_id,
discord_guild_id: guild.id
) do
nil ->
LookingForMiataTimer.changeset(%LookingForMiataTimer{}, %{
joined_at: member.joined_at,
discord_user_id: member.user.id,
joined_at: DateTime.utc_now(),
discord_user_id: member.user_id,
discord_guild_id: guild.id
})
|> Repo.insert!()
Expand Down

0 comments on commit 980b6f4

Please sign in to comment.