Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
xdnw committed Jul 14, 2024
1 parent ad913b1 commit 0a7a348
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/link/locutus/discord/db/GuildHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/link/locutus/discord/db/entities/DBNation.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String> post = new HashMap<>();
Expand All @@ -4693,18 +4694,20 @@ 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);
}
System.out.println("Mail response " + result);
break;
}
return null;
return lastResult;
}

public int estimateBeigeTime() {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 0a7a348

Please sign in to comment.