diff --git a/src/main/java/link/locutus/discord/commands/manager/v2/impl/pw/commands/DiscordCommands.java b/src/main/java/link/locutus/discord/commands/manager/v2/impl/pw/commands/DiscordCommands.java index 22cc8527..38e1210a 100644 --- a/src/main/java/link/locutus/discord/commands/manager/v2/impl/pw/commands/DiscordCommands.java +++ b/src/main/java/link/locutus/discord/commands/manager/v2/impl/pw/commands/DiscordCommands.java @@ -222,6 +222,9 @@ public String channel(NationPlaceholders placeholders, ValueStore store, @Me Gui @Switch("a") boolean pingAuthor ) throws ExecutionException, InterruptedException { + if (category.getGuild().getIdLong() != db.getGuild().getIdLong()) { + throw new IllegalArgumentException("Category is not in the same guild as the command."); + } channelName = placeholders.format2(store, channelName, nation, true); Member member = guild.getMember(author); diff --git a/src/main/java/link/locutus/discord/db/GuildHandler.java b/src/main/java/link/locutus/discord/db/GuildHandler.java index 947a6cef..dd006b54 100644 --- a/src/main/java/link/locutus/discord/db/GuildHandler.java +++ b/src/main/java/link/locutus/discord/db/GuildHandler.java @@ -671,7 +671,7 @@ public JsonObject sendRecruitMessage(DBNation to) throws IOException { String subject = pair.getKey(); String message = pair.getValue(); ApiKeyPool keys = getDb().getMailKey(); - if (keys == null) { + if (keys == null || keys.size() == 0) { boolean hasKey = getDb().getOrNull(GuildKey.API_KEY) != null; if (!hasKey) { throw new IllegalArgumentException("Please set `API_KEY` with " + CM.settings.info.cmd.toSlashMention()); diff --git a/src/main/java/link/locutus/discord/db/entities/DBNation.java b/src/main/java/link/locutus/discord/db/entities/DBNation.java index 99fe9896..904b9eac 100644 --- a/src/main/java/link/locutus/discord/db/entities/DBNation.java +++ b/src/main/java/link/locutus/discord/db/entities/DBNation.java @@ -4672,6 +4672,7 @@ public JsonObject sendMail(ApiKeyPool pool, String subject, String message, bool } } + JsonObject lastResult = null; while (true) { ApiKeyPool.ApiKey pair = pool.getNextApiKey(); Map post = new HashMap<>(); @@ -4693,10 +4694,12 @@ public JsonObject sendMail(ApiKeyPool pool, String subject, String message, bool return JsonParser.parseString(result).getAsJsonObject(); } } + System.out.println("Invalid response " + result); } try { JsonObject obj = JsonParser.parseString(result).getAsJsonObject(); String generalMessage = obj.get("general_message").getAsString(); + lastResult = obj; } catch (JsonSyntaxException e) { System.out.println("Error sending mail to " + getNation_id() + " with key " + pair.getKey()); System.out.println(result); @@ -4704,7 +4707,7 @@ public JsonObject sendMail(ApiKeyPool pool, String subject, String message, bool System.out.println("Mail response " + result); break; } - return null; + return lastResult; } public int estimateBeigeTime() { @@ -5417,7 +5420,7 @@ public int getUnitsAt(MilitaryUnit unit, long date) { return Locutus.imp().getNationDB().getMilitary(this, unit, date); } - @Command(desc = "If there is remaining purchase for a unit today") + @Command(desc = "If a unit was bought today") public boolean hasUnitBuyToday(MilitaryUnit unit) { long turnDayStart; if (getSnapshot() != null) {