SteamWar/BungeeCore
Archiviert
13
2

-21s Start time.

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2021-09-04 22:18:38 +02:00
Ursprung 05c37c0df0
Commit f0e7f52fd6
2 geänderte Dateien mit 13 neuen und 10 gelöschten Zeilen

Datei anzeigen

@ -103,10 +103,10 @@ public class SteamwarDiscordBot {
serverTeamChatListener = new ServerTeamChatListener(); serverTeamChatListener = new ServerTeamChatListener();
new SlashCommandListener(); 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 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(); CommandListUpdateAction commands = jda.getGuildById(SteamwarDiscordBotConfig.GUILD).updateCommands();
addCommand(commands, new MuteCommand()); addCommand(commands, new MuteCommand());
addCommand(commands, new BanCommand()); addCommand(commands, new BanCommand());
@ -114,7 +114,7 @@ public class SteamwarDiscordBot {
addCommand(commands, new TeamCommand()); addCommand(commands, new TeamCommand());
addCommand(commands, new ListCommand()); addCommand(commands, new ListCommand());
addCommand(commands, new UnbanCommand()); addCommand(commands, new UnbanCommand());
commands.complete(); commands.queue();
} }
private void addCommand(CommandListUpdateAction commands, BasicDiscordCommand basicDiscordCommand) { private void addCommand(CommandListUpdateAction commands, BasicDiscordCommand basicDiscordCommand) {

Datei anzeigen

@ -38,10 +38,6 @@ public class DiscordRolesMessage {
public void sendMessage() { public void sendMessage() {
TextChannel channel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.ROLES_CHANNEL); TextChannel channel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.ROLES_CHANNEL);
assert channel != null; 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(); MessageBuilder builder = new MessageBuilder();
builder.setContent(SteamwarDiscordBotConfig.ROLES_BASE_MESSAGE); builder.setContent(SteamwarDiscordBotConfig.ROLES_BASE_MESSAGE);
@ -49,10 +45,17 @@ public class DiscordRolesMessage {
SteamwarDiscordBotConfig.ROLES.forEach(discordRole -> buttons.add(discordRole.toButton())); SteamwarDiscordBotConfig.ROLES.forEach(discordRole -> buttons.add(discordRole.toButton()));
builder.setActionRows(ActionRow.of(buttons)); builder.setActionRows(ActionRow.of(buttons));
if (message != null) { if(channel.hasLatestMessage()) {
message.editMessage(builder.build()).complete(); 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 { } else {
channel.sendMessage(builder.build()).complete(); channel.sendMessage(builder.build()).queue();
} }
} }
} }