Commit 873a6e36 authored by Peter van der meulen's avatar Peter van der meulen

Forgetting users is a thing now

parent 4e21d948
......@@ -20,6 +20,7 @@ config :snuggles_app,
discord_snuggles_id: String.to_integer(System.get_env("DISCORD_SNUGGLES_ID")),
discord_auth_channel_id: String.to_integer(System.get_env("DISCORD_AUTH_CHANNEL_ID")),
discord_admin_channel_id: String.to_integer(System.get_env("DISCORD_ADMIN_CHANNEL_ID")),
discord_admin_id: String.to_integer(System.get_env("DISCORD_ADMIN_ID")),
discord_guild_id: String.to_integer(System.get_env("DISCORD_GUILD_ID")),
discord_default_role_id: String.to_integer(System.get_env("DISCORD_DEFAULT_ROLE_ID")),
discord_all_role_ids: (System.get_env("DISCORD_ALL_ROLE_IDS") |> String.split(",") |> Enum.map(&String.to_integer/1))
......
......@@ -174,6 +174,7 @@ defmodule SnugglesApp.Accounts do
"help" -> Discord.send_admin_help_message(author_id)
"add corp discord" -> send_admin_corp_creation_help_message(author_id)
"rerun " <> _ -> force_user_update(mentions)
"forget "<> mention -> forget_user(author_id, mention)
_ -> Discord.send_admin_fallback_message(author_id)
end
end
......@@ -197,6 +198,19 @@ defmodule SnugglesApp.Accounts do
end
end
defp forget_user(author_id, mention) do
admin_id = Application.get_env(:snuggles_app, :discord_admin_id)
case author_id do
^admin_id ->
discord_user = List.last(Regex.run(~r/<@(.+?)>/, mention))
user = Repo.get_by!(User, discord_id: discord_user)
Repo.delete!(user)
Discord.send_message_to_admin("User has been forgotten")
_ ->
Discord.send_message_to_admin("Only my boss can do that")
end
end
@doc """
Creates corporation
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment