From f0e7f52fd65a8975ba50c9898d7ca3ecd3467d66 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 4 Sep 2021 22:18:38 +0200 Subject: [PATCH] -21s Start time. Signed-off-by: Lixfel --- .../bungeecore/bot/SteamwarDiscordBot.java | 6 +++--- .../bot/util/DiscordRolesMessage.java | 17 ++++++++++------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/de/steamwar/bungeecore/bot/SteamwarDiscordBot.java b/src/de/steamwar/bungeecore/bot/SteamwarDiscordBot.java index 7c5f1db..57d67f5 100644 --- a/src/de/steamwar/bungeecore/bot/SteamwarDiscordBot.java +++ b/src/de/steamwar/bungeecore/bot/SteamwarDiscordBot.java @@ -103,10 +103,10 @@ public class SteamwarDiscordBot { serverTeamChatListener = new ServerTeamChatListener(); new SlashCommandListener(); - jda.retrieveCommands().complete().forEach(command -> jda.deleteCommandById(command.getId()).complete()); + jda.retrieveCommands().complete().forEach(command -> jda.deleteCommandById(command.getId()).queue()); Guild guild = jda.getGuildById(SteamwarDiscordBotConfig.GUILD); - guild.retrieveCommands().complete().forEach(command -> guild.deleteCommandById(command.getId()).complete()); + guild.retrieveCommands().complete().forEach(command -> guild.deleteCommandById(command.getId()).queue()); CommandListUpdateAction commands = jda.getGuildById(SteamwarDiscordBotConfig.GUILD).updateCommands(); addCommand(commands, new MuteCommand()); addCommand(commands, new BanCommand()); @@ -114,7 +114,7 @@ public class SteamwarDiscordBot { addCommand(commands, new TeamCommand()); addCommand(commands, new ListCommand()); addCommand(commands, new UnbanCommand()); - commands.complete(); + commands.queue(); } private void addCommand(CommandListUpdateAction commands, BasicDiscordCommand basicDiscordCommand) { diff --git a/src/de/steamwar/bungeecore/bot/util/DiscordRolesMessage.java b/src/de/steamwar/bungeecore/bot/util/DiscordRolesMessage.java index baa8801..1486deb 100644 --- a/src/de/steamwar/bungeecore/bot/util/DiscordRolesMessage.java +++ b/src/de/steamwar/bungeecore/bot/util/DiscordRolesMessage.java @@ -38,10 +38,6 @@ public class DiscordRolesMessage { public void sendMessage() { TextChannel channel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.ROLES_CHANNEL); assert channel != null; - Message message = null; - if(channel.hasLatestMessage()) { - message = channel.getIterableHistory().complete().stream().filter(m -> m.getAuthor().isBot()).findFirst().orElse(null); - } MessageBuilder builder = new MessageBuilder(); builder.setContent(SteamwarDiscordBotConfig.ROLES_BASE_MESSAGE); @@ -49,10 +45,17 @@ public class DiscordRolesMessage { SteamwarDiscordBotConfig.ROLES.forEach(discordRole -> buttons.add(discordRole.toButton())); builder.setActionRows(ActionRow.of(buttons)); - if (message != null) { - message.editMessage(builder.build()).complete(); + if(channel.hasLatestMessage()) { + channel.getIterableHistory().queue(messages -> { + Message message = messages.stream().filter(m -> m.getAuthor().isBot()).findFirst().orElse(null); + if (message != null) { + message.editMessage(builder.build()).queue(); + } else { + channel.sendMessage(builder.build()).queue(); + } + }); } else { - channel.sendMessage(builder.build()).complete(); + channel.sendMessage(builder.build()).queue(); } } }