Skip to content

Commit

Permalink
add bot spam logs to NewUsersTimer
Browse files Browse the repository at this point in the history
  • Loading branch information
THE9rtyt committed Mar 2, 2024
1 parent 3e89baf commit 2d0f9fc
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion lib/miata_bot_discord/listeners/new_users_listener.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ defmodule MiataBotDiscord.NewUsersListener do
use Quarrel.Listener
alias MiataBot.{Repo, NewUsersTimer}
import Ecto.Query
alias Nostrum.Struct.Embed

@expiry_days 69

def debug_expire_timer(timer, refreshed_at \\ nil) do
Expand Down Expand Up @@ -89,12 +91,36 @@ defmodule MiataBotDiscord.NewUsersListener do
if state.config.accepted_role_id in (new.roles -- old.roles) do
Logger.info("refreshing timer for #{new.user_id}")
timer = ensure_new_user_timer(state.guild, new)

embed =
%Embed{}
|> Embed.put_title("NewUsersTimer")
|> Embed.put_description("Timer Refreshing")
|> Embed.put_field("User: ", "<@#{new.user_id}>")
|> Embed.put_color(0x11FFAA)
|> Embed.put_footer("ID: #{new.user_id}")
|> Embed.put_timestamp(to_string(DateTime.utc_now()))

create_message(state.config.bot_spam_channel_id, embed: embed)

refresh_looking_for_miata_timer(state.guild, timer)
end

if state.config.accepted_role_id in (old.roles -- new.roles) do
Logger.info("refreshing timer for #{new.user_id}")
Logger.info("deleting timer for #{new.user_id}")
timer = ensure_new_user_timer(state.guild, new)

embed =
%Embed{}
|> Embed.put_title("NewUsersTimer")
|> Embed.put_description("Timer Deletion")
|> Embed.put_field("User: ", "<@#{new.user_id}>")
|> Embed.put_color(0xFF0000)
|> Embed.put_footer("ID: #{new.user_id}")
|> Embed.put_timestamp(to_string(DateTime.utc_now()))

create_message(state.config.bot_spam_channel_id, embed: embed)

Repo.delete!(timer)
end

Expand Down Expand Up @@ -131,6 +157,17 @@ defmodule MiataBotDiscord.NewUsersListener do

Logger.info("expiring new user timer for member: #{inspect(member)}")

embed =
%Embed{}
|> Embed.put_title("NewUsersTimer")
|> Embed.put_description("Kicking non-member")
|> Embed.put_field("User: ", "<@#{timer.discord_user_id}>")
|> Embed.put_color(0xFF0000)
|> Embed.put_footer("ID: #{timer.discord_user_id}")
|> Embed.put_timestamp(to_string(DateTime.utc_now()))

create_message(state.config.bot_spam_channel_id, embed: embed)

if(member.roles == [state.config.accepted_role_id]) do
Nostrum.Api.remove_guild_member(state.guild.id, timer.discord_user_id, "afk non-member")
end
Expand Down

0 comments on commit 2d0f9fc

Please sign in to comment.