Commit 760bca25 authored by Peter van der meulen's avatar Peter van der meulen

Unique checks for corp

parent da8ff827
......@@ -175,7 +175,12 @@ defmodule SnugglesApp.Accounts do
def handle_create_corp(object) do
user = Repo.get_by(User, discord_id: Integer.to_string(object["author_id"]))
corp = Repo.get_by(Corporation, discord_guild_id: Integer.to_string(object["guild_id"]))
if user do
corp = Repo.get_by(Corporation, eve_corp_id: user.eve_corp_id)
corp = Repo.get_by(Corporation, discord_guild_id: Integer.to_string(object["guild_id"]))
cond do
user == nil ->
Discord.send_message("Hey <@#{object["author_id"]}>, You need to auth yourself in the alliance first", object["channel_id"])
......@@ -185,7 +190,6 @@ defmodule SnugglesApp.Accounts do
{:ok, _} = create_corp(user, object)
Discord.send_message("Hey #{user.corp_ticker}, \nYour corporation is now registered with its own auth. \nYour members can write `!auth-corp` in the alliance landing pad to receive rights on this server", object["channel_id"])
true ->
Discord.send_message("Hey #{user.corp_ticker}, \nIt looks like i can't read the member role you mentioned, make sure the setting \"All members can mention this role\" is enabled on the member role. If you still experience issues try clicking the autocomplete when mentioning the role. you can also only manage one member role", object["channel_id"])
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