From 40e61f7000d5c6272c4f5693ba50a38390aeb6f8 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Tue, 21 Feb 2023 17:16:27 +0100 Subject: [PATCH] Port Discord Bot to JDA 5.0 --- build.gradle | 2 +- .../steamwar/bungeecore/bot/AuthManager.java | 10 ++-- .../bungeecore/bot/SteamwarDiscordBot.java | 10 ++-- .../bungeecore/bot/commands/BanCommand.java | 10 ++-- .../bot/commands/BasicDiscordCommand.java | 26 ++++++---- .../bungeecore/bot/commands/ListCommand.java | 4 +- .../bungeecore/bot/commands/MuteCommand.java | 10 ++-- .../bungeecore/bot/commands/TeamCommand.java | 12 ++--- .../bungeecore/bot/commands/UnbanCommand.java | 6 +-- .../bungeecore/bot/commands/WhoisCommand.java | 6 +-- .../bungeecore/bot/config/DiscordRole.java | 6 +-- .../bot/config/DiscordRulesLink.java | 2 +- .../bot/config/DiscordTicketType.java | 6 +-- .../bungeecore/bot/events/EventManager.java | 25 +++++---- .../bot/events/SchematicsManager.java | 11 ++-- .../bot/listeners/AnnouncementListener.java | 15 +++--- .../bot/listeners/DiscordAuthListener.java | 4 +- .../bot/listeners/DiscordChatListener.java | 15 +++--- .../bot/listeners/DiscordEventListener.java | 6 +-- .../bot/listeners/DiscordTicketListener.java | 52 +++++++++++-------- .../bot/listeners/PrivateMessageListener.java | 13 +++-- .../RolesInteractionButtonListener.java | 7 +-- .../bot/listeners/SlashCommandListener.java | 4 +- .../bot/util/DiscordRolesMessage.java | 15 +++--- .../bot/util/DiscordRulesMessage.java | 17 +++--- .../bot/util/DiscordSchemAlert.java | 12 ++--- .../bot/util/DiscordTicketMessage.java | 15 +++--- 27 files changed, 174 insertions(+), 147 deletions(-) diff --git a/build.gradle b/build.gradle index 789fc216..6c5ae10b 100644 --- a/build.gradle +++ b/build.gradle @@ -97,7 +97,7 @@ dependencies { compileOnly 'de.steamwar:waterfall:RELEASE' compileOnly 'de.steamwar:persistentbungeecore:RELEASE' - implementation("net.dv8tion:JDA:4.4.0_352") { + implementation("net.dv8tion:JDA:5.0.0-beta.4") { exclude module: 'opus-java' } diff --git a/src/de/steamwar/bungeecore/bot/AuthManager.java b/src/de/steamwar/bungeecore/bot/AuthManager.java index ac4f5539..948c35ca 100644 --- a/src/de/steamwar/bungeecore/bot/AuthManager.java +++ b/src/de/steamwar/bungeecore/bot/AuthManager.java @@ -22,11 +22,11 @@ package de.steamwar.bungeecore.bot; import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig; import de.steamwar.bungeecore.sql.SteamwarUser; -import net.dv8tion.jda.api.MessageBuilder; -import net.dv8tion.jda.api.entities.Emoji; import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.emoji.Emoji; import net.dv8tion.jda.api.interactions.components.ActionRow; -import net.dv8tion.jda.api.interactions.components.Button; +import net.dv8tion.jda.api.interactions.components.buttons.Button; +import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder; import java.util.*; import java.util.concurrent.TimeUnit; @@ -56,9 +56,9 @@ public class AuthManager { Member member = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).retrieveMemberById(TOKENS.get(code).longValue()).complete(); if(member == null) return null; user.setDiscordId(member.getIdLong()); - MessageBuilder builder = new MessageBuilder(); + MessageCreateBuilder builder = new MessageCreateBuilder(); builder.setContent(":white_check_mark: Dein Discord Konto wurde mit **" + user.getUserName() + "** verknüpft"); - builder.setActionRows(ActionRow.of(Button.success("tada", Emoji.fromUnicode("U+1F389")), Button.danger("invalid", "Ich war das nicht"))); + builder.setComponents(ActionRow.of(Button.success("tada", Emoji.fromUnicode("U+1F389")), Button.danger("invalid", "Ich war das nicht"))); try { member.getUser().openPrivateChannel().queue(privateChannel -> privateChannel.sendMessage(builder.build()).queue()); diff --git a/src/de/steamwar/bungeecore/bot/SteamwarDiscordBot.java b/src/de/steamwar/bungeecore/bot/SteamwarDiscordBot.java index 3811c185..cfa552f8 100644 --- a/src/de/steamwar/bungeecore/bot/SteamwarDiscordBot.java +++ b/src/de/steamwar/bungeecore/bot/SteamwarDiscordBot.java @@ -76,11 +76,7 @@ public class SteamwarDiscordBot { JDABuilder builder = JDABuilder.createDefault(SteamwarDiscordBotConfig.TOKEN); builder.setStatus(OnlineStatus.ONLINE); builder.setMemberCachePolicy(MemberCachePolicy.ONLINE); - try { - jda = builder.build(); - } catch (LoginException e) { - throw new SecurityException("Could not Login: " + SteamwarDiscordBotConfig.TOKEN, e); - } + jda = builder.build(); ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> { try { jda.awaitReady(); @@ -131,8 +127,8 @@ public class SteamwarDiscordBot { } private void addCommand(CommandListUpdateAction commands, BasicDiscordCommand basicDiscordCommand) { - commands.addCommands(basicDiscordCommand); - discordCommandMap.put(basicDiscordCommand.getName(), basicDiscordCommand); + commands.addCommands(basicDiscordCommand.getData()); + discordCommandMap.put(basicDiscordCommand.getData().getName(), basicDiscordCommand); } private int index = 0; diff --git a/src/de/steamwar/bungeecore/bot/commands/BanCommand.java b/src/de/steamwar/bungeecore/bot/commands/BanCommand.java index e3289975..7acf7227 100644 --- a/src/de/steamwar/bungeecore/bot/commands/BanCommand.java +++ b/src/de/steamwar/bungeecore/bot/commands/BanCommand.java @@ -23,7 +23,7 @@ import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.commands.PunishmentCommand; import de.steamwar.bungeecore.sql.Punishment; import de.steamwar.bungeecore.sql.SteamwarUser; -import net.dv8tion.jda.api.events.interaction.SlashCommandEvent; +import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; import net.dv8tion.jda.api.interactions.commands.OptionType; import java.sql.Timestamp; @@ -33,13 +33,13 @@ public class BanCommand extends BasicDiscordCommand { public BanCommand() { super("ban", "Banne einen Nutzer, wenn du die Rechte hast."); - addOption(OptionType.STRING, "user", "Der Benutzer", true); - addOption(OptionType.STRING, "time", "Bis Wann", true); - addOption(OptionType.STRING, "reason", "Warum", true); + getData().addOption(OptionType.STRING, "user", "Der Benutzer", true); + getData().addOption(OptionType.STRING, "time", "Bis Wann", true); + getData().addOption(OptionType.STRING, "reason", "Warum", true); } @Override - public void run(SlashCommandEvent event) { + public void run(SlashCommandInteractionEvent event) { if (!testPermission(event)) { return; } diff --git a/src/de/steamwar/bungeecore/bot/commands/BasicDiscordCommand.java b/src/de/steamwar/bungeecore/bot/commands/BasicDiscordCommand.java index 29bbe85d..a82e6e3e 100644 --- a/src/de/steamwar/bungeecore/bot/commands/BasicDiscordCommand.java +++ b/src/de/steamwar/bungeecore/bot/commands/BasicDiscordCommand.java @@ -22,27 +22,33 @@ package de.steamwar.bungeecore.bot.commands; import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.UserGroup; import net.dv8tion.jda.api.entities.Member; -import net.dv8tion.jda.api.events.interaction.SlashCommandEvent; -import net.dv8tion.jda.api.interactions.commands.build.CommandData; +import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; +import net.dv8tion.jda.api.hooks.ListenerAdapter; +import net.dv8tion.jda.api.interactions.commands.build.Commands; +import net.dv8tion.jda.api.interactions.commands.build.SlashCommandData; +import org.jetbrains.annotations.NotNull; -public abstract class BasicDiscordCommand extends CommandData { +public abstract class BasicDiscordCommand { + + private final SlashCommandData data; protected BasicDiscordCommand(String name, String description) { - super(name, description); + data = Commands.slash(name, description); } - public abstract void run(SlashCommandEvent event); + public SlashCommandData getData() { + return data; + } - protected SteamwarUser getSteamwarUser(SlashCommandEvent event) { + public abstract void run(SlashCommandInteractionEvent event); + + protected SteamwarUser getSteamwarUser(SlashCommandInteractionEvent event) { Member member = event.getMember(); SteamwarUser steamwarUser = SteamwarUser.get(member.getIdLong()); - if (steamwarUser == null) { - return null; - } return steamwarUser; } - protected boolean testPermission(SlashCommandEvent event) { + protected boolean testPermission(SlashCommandInteractionEvent event) { Member member = event.getMember(); SteamwarUser steamwarUser = SteamwarUser.get(member.getIdLong()); if (steamwarUser == null || (!steamwarUser.getUserGroup().isTeamGroup() && steamwarUser.getUserGroup() != UserGroup.Builder)) { diff --git a/src/de/steamwar/bungeecore/bot/commands/ListCommand.java b/src/de/steamwar/bungeecore/bot/commands/ListCommand.java index 746bb026..18f28840 100644 --- a/src/de/steamwar/bungeecore/bot/commands/ListCommand.java +++ b/src/de/steamwar/bungeecore/bot/commands/ListCommand.java @@ -20,7 +20,7 @@ package de.steamwar.bungeecore.bot.commands; import net.dv8tion.jda.api.EmbedBuilder; -import net.dv8tion.jda.api.events.interaction.SlashCommandEvent; +import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; import java.util.stream.Collectors; @@ -31,7 +31,7 @@ public class ListCommand extends BasicDiscordCommand { } @Override - public void run(SlashCommandEvent event) { + public void run(SlashCommandInteractionEvent event) { de.steamwar.bungeecore.commands.ListCommand.getCustomTablist(); EmbedBuilder embedBuilder = new EmbedBuilder(); embedBuilder.setTitle("List"); diff --git a/src/de/steamwar/bungeecore/bot/commands/MuteCommand.java b/src/de/steamwar/bungeecore/bot/commands/MuteCommand.java index 086cf778..792ea4a5 100644 --- a/src/de/steamwar/bungeecore/bot/commands/MuteCommand.java +++ b/src/de/steamwar/bungeecore/bot/commands/MuteCommand.java @@ -23,7 +23,7 @@ import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.commands.PunishmentCommand; import de.steamwar.bungeecore.sql.Punishment; import de.steamwar.bungeecore.sql.SteamwarUser; -import net.dv8tion.jda.api.events.interaction.SlashCommandEvent; +import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; import net.dv8tion.jda.api.interactions.commands.OptionType; import java.sql.Timestamp; @@ -33,13 +33,13 @@ public class MuteCommand extends BasicDiscordCommand { public MuteCommand() { super("mute", "Mute einen Nutzer, wenn du die Rechte hast."); - addOption(OptionType.STRING, "user", "Der Benutzer", true); - addOption(OptionType.STRING, "time", "Bis Wann", true); - addOption(OptionType.STRING, "reason", "Warum", true); + getData().addOption(OptionType.STRING, "user", "Der Benutzer", true); + getData().addOption(OptionType.STRING, "time", "Bis Wann", true); + getData().addOption(OptionType.STRING, "reason", "Warum", true); } @Override - public void run(SlashCommandEvent event) { + public void run(SlashCommandInteractionEvent event) { if (!testPermission(event)) { return; } diff --git a/src/de/steamwar/bungeecore/bot/commands/TeamCommand.java b/src/de/steamwar/bungeecore/bot/commands/TeamCommand.java index e0b35453..21991235 100644 --- a/src/de/steamwar/bungeecore/bot/commands/TeamCommand.java +++ b/src/de/steamwar/bungeecore/bot/commands/TeamCommand.java @@ -24,8 +24,8 @@ import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.Team; import de.steamwar.bungeecore.sql.TeamTeilnahme; import net.dv8tion.jda.api.EmbedBuilder; -import net.dv8tion.jda.api.entities.Emoji; -import net.dv8tion.jda.api.events.interaction.SlashCommandEvent; +import net.dv8tion.jda.api.entities.emoji.Emoji; +import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; import net.dv8tion.jda.api.interactions.commands.OptionMapping; import net.dv8tion.jda.api.interactions.commands.OptionType; import net.dv8tion.jda.api.interactions.commands.build.SubcommandData; @@ -40,7 +40,7 @@ public class TeamCommand extends BasicDiscordCommand { public TeamCommand() { super("team", "Alle Team bezogenen Befehle"); - addSubcommands(new SubcommandData("info", "Infos über das Team oder deins") + getData().addSubcommands(new SubcommandData("info", "Infos über das Team oder deins") .addOption(OptionType.STRING, "team", "Name oder Kuerzel", false) ); } @@ -48,7 +48,7 @@ public class TeamCommand extends BasicDiscordCommand { private Emoji emoji = Emoji.fromUnicode("U+1F7E2"); @Override - public void run(SlashCommandEvent event) { + public void run(SlashCommandInteractionEvent event) { SteamwarUser steamwarUser = getSteamwarUser(event); if (event.getSubcommandName() != null) { @@ -78,8 +78,8 @@ public class TeamCommand extends BasicDiscordCommand { embedBuilder.setColor(Color.GRAY); List members = team.getMembers().stream().map(SteamwarUser::get).collect(Collectors.toList()); - embedBuilder.addField("Leader", members.stream().filter(SteamwarUser::isLeader).map(user -> "`" + (isOnline(user) ? emoji.getAsMention() : "") + user.getUserName() + "`").collect(Collectors.joining(" ")), false); - embedBuilder.addField("Member", members.stream().filter(user -> !user.isLeader()).map(user -> "`" + (isOnline(user) ? emoji.getAsMention() : "") + user.getUserName() + "`").collect(Collectors.joining(" ")), false); + embedBuilder.addField("Leader", members.stream().filter(SteamwarUser::isLeader).map(user -> "`" + (isOnline(user) ? emoji.getAsReactionCode() : "") + user.getUserName() + "`").collect(Collectors.joining(" ")), false); + embedBuilder.addField("Member", members.stream().filter(user -> !user.isLeader()).map(user -> "`" + (isOnline(user) ? emoji.getAsReactionCode() : "") + user.getUserName() + "`").collect(Collectors.joining(" ")), false); embedBuilder.addField("Events", "`" + TeamTeilnahme.getEvents(team.getTeamId()).stream().map(Event::getEventName).collect(Collectors.joining("` `")) + "`", false); event.replyEmbeds(embedBuilder.build()).setEphemeral(true).queue(); return; diff --git a/src/de/steamwar/bungeecore/bot/commands/UnbanCommand.java b/src/de/steamwar/bungeecore/bot/commands/UnbanCommand.java index f8d6185d..4ffba5df 100644 --- a/src/de/steamwar/bungeecore/bot/commands/UnbanCommand.java +++ b/src/de/steamwar/bungeecore/bot/commands/UnbanCommand.java @@ -21,7 +21,7 @@ package de.steamwar.bungeecore.bot.commands; import de.steamwar.bungeecore.sql.Punishment; import de.steamwar.bungeecore.sql.SteamwarUser; -import net.dv8tion.jda.api.events.interaction.SlashCommandEvent; +import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; import net.dv8tion.jda.api.interactions.commands.OptionType; import java.sql.Timestamp; @@ -32,11 +32,11 @@ public class UnbanCommand extends BasicDiscordCommand { public UnbanCommand() { super("unban", "Entbannt einen Nutzer, wenn du die Rechte hast."); - addOption(OptionType.STRING, "user", "Der Benutzer", true); + getData().addOption(OptionType.STRING, "user", "Der Benutzer", true); } @Override - public void run(SlashCommandEvent event) { + public void run(SlashCommandInteractionEvent event) { if (!testPermission(event)) { return; } diff --git a/src/de/steamwar/bungeecore/bot/commands/WhoisCommand.java b/src/de/steamwar/bungeecore/bot/commands/WhoisCommand.java index 8608047c..3df56ffe 100644 --- a/src/de/steamwar/bungeecore/bot/commands/WhoisCommand.java +++ b/src/de/steamwar/bungeecore/bot/commands/WhoisCommand.java @@ -23,7 +23,7 @@ import de.steamwar.bungeecore.sql.Punishment; import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.Team; import net.dv8tion.jda.api.EmbedBuilder; -import net.dv8tion.jda.api.events.interaction.SlashCommandEvent; +import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; import net.dv8tion.jda.api.interactions.commands.OptionType; import java.sql.Timestamp; @@ -35,11 +35,11 @@ public class WhoisCommand extends BasicDiscordCommand { public WhoisCommand() { super("whois", "Der whois Befehl"); - addOption(OptionType.STRING, "user", "Der Benutzer", true); + getData().addOption(OptionType.STRING, "user", "Der Benutzer", true); } @Override - public void run(SlashCommandEvent event) { + public void run(SlashCommandInteractionEvent event) { if (!testPermission(event)) { return; } diff --git a/src/de/steamwar/bungeecore/bot/config/DiscordRole.java b/src/de/steamwar/bungeecore/bot/config/DiscordRole.java index 68b57bee..c0b57aab 100644 --- a/src/de/steamwar/bungeecore/bot/config/DiscordRole.java +++ b/src/de/steamwar/bungeecore/bot/config/DiscordRole.java @@ -21,9 +21,9 @@ package de.steamwar.bungeecore.bot.config; import lombok.AllArgsConstructor; import lombok.Data; -import net.dv8tion.jda.api.entities.Emoji; -import net.dv8tion.jda.api.interactions.components.Button; -import net.dv8tion.jda.api.interactions.components.ButtonStyle; +import net.dv8tion.jda.api.entities.emoji.Emoji; +import net.dv8tion.jda.api.interactions.components.buttons.Button; +import net.dv8tion.jda.api.interactions.components.buttons.ButtonStyle; @Data @AllArgsConstructor diff --git a/src/de/steamwar/bungeecore/bot/config/DiscordRulesLink.java b/src/de/steamwar/bungeecore/bot/config/DiscordRulesLink.java index 4f2ebe01..4cc041f9 100644 --- a/src/de/steamwar/bungeecore/bot/config/DiscordRulesLink.java +++ b/src/de/steamwar/bungeecore/bot/config/DiscordRulesLink.java @@ -21,7 +21,7 @@ package de.steamwar.bungeecore.bot.config; import lombok.AllArgsConstructor; import lombok.Data; -import net.dv8tion.jda.api.interactions.components.Button; +import net.dv8tion.jda.api.interactions.components.buttons.Button; @Data @AllArgsConstructor diff --git a/src/de/steamwar/bungeecore/bot/config/DiscordTicketType.java b/src/de/steamwar/bungeecore/bot/config/DiscordTicketType.java index 5ba4c654..28e25655 100644 --- a/src/de/steamwar/bungeecore/bot/config/DiscordTicketType.java +++ b/src/de/steamwar/bungeecore/bot/config/DiscordTicketType.java @@ -21,9 +21,9 @@ package de.steamwar.bungeecore.bot.config; import lombok.AllArgsConstructor; import lombok.Data; -import net.dv8tion.jda.api.entities.Emoji; -import net.dv8tion.jda.api.interactions.components.Button; -import net.dv8tion.jda.api.interactions.components.ButtonStyle; +import net.dv8tion.jda.api.entities.emoji.Emoji; +import net.dv8tion.jda.api.interactions.components.buttons.Button; +import net.dv8tion.jda.api.interactions.components.buttons.ButtonStyle; @Data @AllArgsConstructor diff --git a/src/de/steamwar/bungeecore/bot/events/EventManager.java b/src/de/steamwar/bungeecore/bot/events/EventManager.java index 79ef2e3b..d0e35444 100644 --- a/src/de/steamwar/bungeecore/bot/events/EventManager.java +++ b/src/de/steamwar/bungeecore/bot/events/EventManager.java @@ -27,12 +27,15 @@ import de.steamwar.bungeecore.sql.Team; import de.steamwar.bungeecore.sql.TeamTeilnahme; import lombok.experimental.UtilityClass; import net.dv8tion.jda.api.EmbedBuilder; -import net.dv8tion.jda.api.MessageBuilder; -import net.dv8tion.jda.api.entities.Emoji; import net.dv8tion.jda.api.entities.Message; -import net.dv8tion.jda.api.entities.TextChannel; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; +import net.dv8tion.jda.api.entities.emoji.Emoji; import net.dv8tion.jda.api.interactions.components.ActionRow; -import net.dv8tion.jda.api.interactions.components.selections.SelectionMenu; +import net.dv8tion.jda.api.interactions.components.Component; +import net.dv8tion.jda.api.interactions.components.selections.SelectMenu; +import net.dv8tion.jda.api.interactions.components.selections.StringSelectMenu; +import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder; +import net.dv8tion.jda.api.utils.messages.MessageEditData; import java.awt.*; import java.sql.Timestamp; @@ -50,7 +53,7 @@ public class EventManager { static { textChannel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.EVENTS_CHANNEL); assert textChannel != null; - if(textChannel.hasLatestMessage()) { + if(textChannel.getLatestMessageIdLong() != 0) { message = textChannel.getIterableHistory().complete().stream().filter(m -> m.getAuthor().isBot()).findFirst().orElse(null); } } @@ -70,7 +73,7 @@ public class EventManager { embedBuilder.setAuthor("SteamWar", "https://www.steamwar.de"); Timestamp now = Timestamp.from(Instant.now()); - SelectionMenu.Builder menuBuilder = SelectionMenu.create("eventName"); + StringSelectMenu.Builder menuBuilder = StringSelectMenu.create("eventName"); menuBuilder.setPlaceholder("Wähle ein Event aus!") .setMinValues(1) .setMaxValues(1); @@ -91,15 +94,15 @@ public class EventManager { } }); - MessageBuilder messageBuilder = new MessageBuilder(); + MessageCreateBuilder messageBuilder = new MessageCreateBuilder(); messageBuilder.setEmbeds(embedBuilder.build()); if(events.stream().anyMatch(event -> event.getDeadline().after(Timestamp.from(Instant.now())))) { - messageBuilder.setActionRows(ActionRow.of(menuBuilder.build())); + messageBuilder.setComponents(ActionRow.of(menuBuilder.build())); } if (message == null) { message = textChannel.sendMessage(messageBuilder.build()).complete(); } else { - message.editMessage(messageBuilder.build()).complete(); + message.editMessage(MessageEditData.fromCreateData(messageBuilder.build())).complete(); } } @@ -131,12 +134,12 @@ public class EventManager { embedBuilder.addField(teamBlue.getTeamKuerzel() + " vs. " + teamRed.getTeamKuerzel(), st.toString(), true); }); - MessageBuilder messageBuilder = new MessageBuilder(); + MessageCreateBuilder messageBuilder = new MessageCreateBuilder(); messageBuilder.setEmbeds(embedBuilder.build()); if (message == null) { textChannel.sendMessage(messageBuilder.build()).queue(message1 -> message = message1); } else { - message.editMessage(messageBuilder.build()).complete(); + message.editMessage(MessageEditData.fromCreateData(messageBuilder.build())).complete(); } } diff --git a/src/de/steamwar/bungeecore/bot/events/SchematicsManager.java b/src/de/steamwar/bungeecore/bot/events/SchematicsManager.java index e407cf98..da158f12 100644 --- a/src/de/steamwar/bungeecore/bot/events/SchematicsManager.java +++ b/src/de/steamwar/bungeecore/bot/events/SchematicsManager.java @@ -25,9 +25,10 @@ import de.steamwar.bungeecore.commands.CheckCommand; import de.steamwar.bungeecore.sql.SteamwarUser; import lombok.experimental.UtilityClass; import net.dv8tion.jda.api.EmbedBuilder; -import net.dv8tion.jda.api.MessageBuilder; import net.dv8tion.jda.api.entities.Message; -import net.dv8tion.jda.api.entities.TextChannel; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; +import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder; +import net.dv8tion.jda.api.utils.messages.MessageEditData; import java.awt.*; @@ -40,7 +41,7 @@ public class SchematicsManager { static { textChannel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.SCHEMATICS_CHANNEL); assert textChannel != null; - if(textChannel.hasLatestMessage()) { + if(textChannel.getLatestMessageIdLong() != 0) { message = textChannel.getIterableHistory().complete().stream().filter(m -> m.getAuthor().isBot()).findFirst().orElse(null); } } @@ -62,12 +63,12 @@ public class SchematicsManager { embedBuilder.addField(schematic.getName(), st.toString(), true); }); - MessageBuilder messageBuilder = new MessageBuilder(); + MessageCreateBuilder messageBuilder = new MessageCreateBuilder(); messageBuilder.setEmbeds(embedBuilder.build()); if (message == null) { textChannel.sendMessage(messageBuilder.build()).queue(message1 -> message = message1); } else { - message.editMessage(messageBuilder.build()).queue(); + message.editMessage(MessageEditData.fromCreateData(messageBuilder.build())).queue(); } } } diff --git a/src/de/steamwar/bungeecore/bot/listeners/AnnouncementListener.java b/src/de/steamwar/bungeecore/bot/listeners/AnnouncementListener.java index ab4be193..229cea7a 100644 --- a/src/de/steamwar/bungeecore/bot/listeners/AnnouncementListener.java +++ b/src/de/steamwar/bungeecore/bot/listeners/AnnouncementListener.java @@ -22,15 +22,18 @@ package de.steamwar.bungeecore.bot.listeners; import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.bot.SteamwarDiscordBot; import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig; -import net.dv8tion.jda.api.MessageBuilder; -import net.dv8tion.jda.api.entities.TextChannel; -import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; +import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder; import org.jetbrains.annotations.NotNull; public class AnnouncementListener extends BasicDiscordListener { @Override - public void onGuildMessageReceived(@NotNull GuildMessageReceivedEvent event) { + public void onMessageReceived(@NotNull MessageReceivedEvent event) { + if(!event.isFromGuild()) { + return; + } if (!event.getChannel().getId().equals(SteamwarDiscordBotConfig.ANNOUNCEMENTS_CHANNEL)) { return; } @@ -43,8 +46,8 @@ public class AnnouncementListener extends BasicDiscordListener { public void announce(String message) { TextChannel textChannel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.ANNOUNCEMENTS_CHANNEL); assert textChannel != null; - MessageBuilder messageBuilder = new MessageBuilder(); - messageBuilder.append(message.replace("&", "")); + MessageCreateBuilder messageBuilder = new MessageCreateBuilder(); + messageBuilder.setContent(message.replace("&", "")); textChannel.sendMessage(messageBuilder.build()).queue(); } } diff --git a/src/de/steamwar/bungeecore/bot/listeners/DiscordAuthListener.java b/src/de/steamwar/bungeecore/bot/listeners/DiscordAuthListener.java index 8ad34282..3d85caaf 100644 --- a/src/de/steamwar/bungeecore/bot/listeners/DiscordAuthListener.java +++ b/src/de/steamwar/bungeecore/bot/listeners/DiscordAuthListener.java @@ -22,8 +22,8 @@ package de.steamwar.bungeecore.bot.listeners; import de.steamwar.bungeecore.bot.AuthManager; import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig; import de.steamwar.bungeecore.sql.SteamwarUser; -import net.dv8tion.jda.api.entities.ChannelType; -import net.dv8tion.jda.api.events.interaction.GenericComponentInteractionCreateEvent; +import net.dv8tion.jda.api.entities.channel.ChannelType; +import net.dv8tion.jda.api.events.interaction.component.GenericComponentInteractionCreateEvent; import net.dv8tion.jda.api.interactions.InteractionType; import org.jetbrains.annotations.NotNull; diff --git a/src/de/steamwar/bungeecore/bot/listeners/DiscordChatListener.java b/src/de/steamwar/bungeecore/bot/listeners/DiscordChatListener.java index 70004ac4..47d6bb6a 100644 --- a/src/de/steamwar/bungeecore/bot/listeners/DiscordChatListener.java +++ b/src/de/steamwar/bungeecore/bot/listeners/DiscordChatListener.java @@ -25,10 +25,10 @@ import de.steamwar.bungeecore.listeners.ChatListener; import de.steamwar.bungeecore.sql.Punishment; import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.messages.ChatSender; -import net.dv8tion.jda.api.MessageBuilder; import net.dv8tion.jda.api.entities.Member; -import net.dv8tion.jda.api.entities.TextChannel; -import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; +import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder; import org.jetbrains.annotations.NotNull; import java.util.function.Supplier; @@ -48,7 +48,10 @@ public class DiscordChatListener extends BasicDiscordListener { } @Override - public void onGuildMessageReceived(@NotNull GuildMessageReceivedEvent event) { + public void onMessageReceived(@NotNull MessageReceivedEvent event) { + if(!event.isFromGuild()) { + return; + } if (!event.getChannel().getId().equals(channel) || event.getAuthor().isBot()) return; @@ -64,8 +67,8 @@ public class DiscordChatListener extends BasicDiscordListener { public void send(String message) { TextChannel textChannel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(channel); assert textChannel != null; - MessageBuilder messageBuilder = new MessageBuilder(); - messageBuilder.append(message.replace("&", "").replace("@everyone", "`@everyone`").replace("@here", "`@here`").replaceAll("<[@#]!?\\d+>", "`$0`")); + MessageCreateBuilder messageBuilder = new MessageCreateBuilder(); + messageBuilder.setContent(message.replace("&", "").replace("@everyone", "`@everyone`").replace("@here", "`@here`").replaceAll("<[@#]!?\\d+>", "`$0`")); textChannel.sendMessage(messageBuilder.build()).queue(); } } diff --git a/src/de/steamwar/bungeecore/bot/listeners/DiscordEventListener.java b/src/de/steamwar/bungeecore/bot/listeners/DiscordEventListener.java index a08f74d2..031ae4d7 100644 --- a/src/de/steamwar/bungeecore/bot/listeners/DiscordEventListener.java +++ b/src/de/steamwar/bungeecore/bot/listeners/DiscordEventListener.java @@ -25,7 +25,7 @@ import de.steamwar.bungeecore.sql.Event; import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.Team; import de.steamwar.bungeecore.sql.TeamTeilnahme; -import net.dv8tion.jda.api.events.interaction.SelectionMenuEvent; +import net.dv8tion.jda.api.events.interaction.component.StringSelectInteractionEvent; import net.dv8tion.jda.api.interactions.components.Component; import org.jetbrains.annotations.NotNull; @@ -35,8 +35,8 @@ public class DiscordEventListener extends BasicDiscordListener { @Override - public void onSelectionMenu(@NotNull SelectionMenuEvent event) { - if(event.getChannel().getId().equals(SteamwarDiscordBotConfig.EVENTS_CHANNEL) && event.getComponentType() == Component.Type.SELECTION_MENU) { + public void onStringSelectInteraction(@NotNull StringSelectInteractionEvent event) { + if(event.getChannel().getId().equals(SteamwarDiscordBotConfig.EVENTS_CHANNEL) && event.getComponentType() == Component.Type.STRING_SELECT) { if(event.getSelectedOptions().isEmpty()) { event.deferReply(true).queue(); return; diff --git a/src/de/steamwar/bungeecore/bot/listeners/DiscordTicketListener.java b/src/de/steamwar/bungeecore/bot/listeners/DiscordTicketListener.java index f7a2fa22..1f0a941b 100644 --- a/src/de/steamwar/bungeecore/bot/listeners/DiscordTicketListener.java +++ b/src/de/steamwar/bungeecore/bot/listeners/DiscordTicketListener.java @@ -25,18 +25,22 @@ import de.steamwar.bungeecore.bot.config.DiscordTicketType; import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig; import de.steamwar.bungeecore.sql.SteamwarUser; import net.dv8tion.jda.api.EmbedBuilder; -import net.dv8tion.jda.api.MessageBuilder; import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.entities.*; -import net.dv8tion.jda.api.events.interaction.GenericComponentInteractionCreateEvent; -import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; +import net.dv8tion.jda.api.entities.channel.ChannelType; +import net.dv8tion.jda.api.entities.channel.concrete.Category; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; +import net.dv8tion.jda.api.entities.emoji.Emoji; +import net.dv8tion.jda.api.events.interaction.component.GenericComponentInteractionCreateEvent; +import net.dv8tion.jda.api.events.message.MessageReceivedEvent; import net.dv8tion.jda.api.interactions.InteractionType; import net.dv8tion.jda.api.interactions.components.ActionRow; -import net.dv8tion.jda.api.interactions.components.Button; +import net.dv8tion.jda.api.interactions.components.buttons.Button; +import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder; import net.md_5.bungee.api.chat.ClickEvent; import org.jetbrains.annotations.NotNull; -import java.awt.*; +import java.awt.Color; import java.time.Instant; import java.util.LinkedList; @@ -44,22 +48,21 @@ public class DiscordTicketListener extends BasicDiscordListener { @Override public void onGenericComponentInteractionCreate(@NotNull GenericComponentInteractionCreateEvent event) { - if(event.getType() == InteractionType.COMPONENT && event.getChannelType() == ChannelType.TEXT && event.getTextChannel().getParent() != null && event.getTextChannel().getParent().getId().equals(SteamwarDiscordBotConfig.TICKET_CATEGORY)) { - if(event.getTextChannel().getId().equals(SteamwarDiscordBotConfig.TICKET_CHANNEL) && SteamwarDiscordBotConfig.TICKET_TYPES.containsKey(event.getComponentId())) { + if(event.getType() == InteractionType.COMPONENT && event.getChannelType() == ChannelType.TEXT && event.getChannel().asTextChannel().getParentCategoryIdLong() != 0 && event.getChannel().asTextChannel().getParentCategoryId().equals(SteamwarDiscordBotConfig.TICKET_CATEGORY)) { + if(event.getChannel().getId().equals(SteamwarDiscordBotConfig.TICKET_CHANNEL) && SteamwarDiscordBotConfig.TICKET_TYPES.containsKey(event.getComponentId())) { DiscordTicketType ticketType = SteamwarDiscordBotConfig.TICKET_TYPES.get(event.getComponentId()); Category ct = event.getGuild().getCategoryById(SteamwarDiscordBotConfig.TICKET_CATEGORY); SteamwarUser swUser = SteamwarUser.get(event.getUser().getIdLong()); TextChannel ticketChannel = ct.createTextChannel((swUser == null?event.getUser().getName():swUser.getUserName()) + "-" + event.getComponentId() + "-" + System.currentTimeMillis() % 1000).complete(); - ticketChannel.createPermissionOverride(event.getMember()).setAllow(Permission.VIEW_CHANNEL, - Permission.MESSAGE_WRITE, + ticketChannel.upsertPermissionOverride(event.getMember()).setAllowed(Permission.VIEW_CHANNEL, + Permission.MESSAGE_SEND, Permission.MESSAGE_ATTACH_FILES, Permission.MESSAGE_ADD_REACTION, - Permission.MESSAGE_READ, Permission.MESSAGE_EMBED_LINKS, Permission.MESSAGE_HISTORY).complete(); ticketChannel.getManager().setTopic(event.getUser().getId()).complete(); - MessageBuilder messageBuilder = new MessageBuilder(); + MessageCreateBuilder messageBuilder = new MessageCreateBuilder(); EmbedBuilder builder = new EmbedBuilder(); builder.setDescription(ticketType.getPreMessage()); builder.setTitle("Steamwar Ticket"); @@ -67,7 +70,7 @@ public class DiscordTicketListener extends BasicDiscordListener { Button closeButton = Button.danger("close-" + ticketChannel.getName(), "Schließen").withEmoji(Emoji.fromUnicode("U+26A0")); messageBuilder.setEmbeds(builder.build()); - messageBuilder.setActionRows(ActionRow.of(closeButton)); + messageBuilder.setComponents(ActionRow.of(closeButton)); ticketChannel.sendMessage(messageBuilder.build()).complete(); event.reply(SteamwarDiscordBotConfig.TICKET_CREATED.replace("%channel%", ticketChannel.getAsMention())).setEphemeral(true).complete(); @@ -78,7 +81,7 @@ public class DiscordTicketListener extends BasicDiscordListener { LinkedList stringBuilders = new LinkedList<>(); stringBuilders.add(new StringBuilder()); - new LinkedList<>(event.getTextChannel().getIterableHistory().complete()).descendingIterator().forEachRemaining(message -> { + new LinkedList<>(event.getChannel().asTextChannel().getIterableHistory().complete()).descendingIterator().forEachRemaining(message -> { if(message.getAuthor().isSystem() || message.getAuthor().isBot()) return; StringBuilder currentBuilder = new StringBuilder(); currentBuilder.append(" ") @@ -112,39 +115,42 @@ public class DiscordTicketListener extends BasicDiscordListener { EmbedBuilder embedBuilder = new EmbedBuilder(); embedBuilder.setColor(Color.GREEN); - User user = event.getJDA().retrieveUserById(event.getTextChannel().getTopic()).complete(); + User user = event.getJDA().retrieveUserById(event.getChannel().asTextChannel().getTopic()).complete(); SteamwarUser swuser = SteamwarUser.get(user.getIdLong()); embedBuilder.setAuthor(user.getName(), swuser==null?"https://steamwar.de/":("https://steamwar.de/users/" + swuser.getUserName().toLowerCase() + "/"), user.getAvatarUrl()); embedBuilder.setTimestamp(Instant.now()); - embedBuilder.setTitle(event.getTextChannel().getName()); + embedBuilder.setTitle(event.getChannel().asTextChannel().getName()); stringBuilders.forEach(stringBuilder -> { embedBuilder.setDescription(stringBuilder.toString()); - MessageBuilder builder = new MessageBuilder(); + MessageCreateBuilder builder = new MessageCreateBuilder(); builder.setEmbeds(embedBuilder.build()); logChannel.sendMessage(builder.build()).queue(); }); - Message.team("DISCORD_TICKET_CLOSED", event.getTextChannel().getName()); - event.getTextChannel().delete().reason("Closed").queue(); + Message.team("DISCORD_TICKET_CLOSED", event.getChannel().getName()); + event.getChannel().asTextChannel().delete().reason("Closed").queue(); } } } @Override - public void onGuildMessageReceived(@NotNull GuildMessageReceivedEvent event) { - if(event.getChannel().getParent() != null && event.getChannel().getParent().getId().equals(SteamwarDiscordBotConfig.TICKET_CATEGORY)) { + public void onMessageReceived(@NotNull MessageReceivedEvent event) { + if(!event.isFromGuild()) { + return; + } + if(event.getChannel().asTextChannel().getParentCategoryIdLong() != 0 && event.getChannel().asTextChannel().getParentCategoryId().equals(SteamwarDiscordBotConfig.TICKET_CATEGORY)) { if(!event.getChannel().getId().equals(SteamwarDiscordBotConfig.TICKET_CHANNEL) && !event.getChannel().getId().equals(SteamwarDiscordBotConfig.TICKET_LOG)) { BungeeCore.get().getProxy().getPlayers().forEach(player -> { if(event.getAuthor().isBot() || event.getAuthor().isSystem()) return; SteamwarUser user = SteamwarUser.get(player); boolean sendMessage; if(user.getDiscordId() == null) { - sendMessage = user.getUserGroup().isCheckSchematics(); + sendMessage = user.getUserGroup().isCheckSchematics(); } else { - if(event.getAuthor().getId().equals(user.getDiscordId())) return; - sendMessage = user.getDiscordId().equals(event.getChannel().getTopic()) || user.getUserGroup().isCheckSchematics(); + if(event.getAuthor().getIdLong() == user.getDiscordId()) return; + sendMessage = user.getDiscordId().toString().equals(event.getChannel().asTextChannel().getTopic()) || user.getUserGroup().isCheckSchematics(); } if(sendMessage) { Message.sendPrefixless("DISCORD_TICKET_MESSAGE", player, "Zur nachricht", new ClickEvent(ClickEvent.Action.OPEN_URL, event.getMessage().getJumpUrl()), event.getChannel().getName(), event.getAuthor().getName(), event.getMessage().getContentRaw()); diff --git a/src/de/steamwar/bungeecore/bot/listeners/PrivateMessageListener.java b/src/de/steamwar/bungeecore/bot/listeners/PrivateMessageListener.java index 8aafe2f6..fbad3c0c 100644 --- a/src/de/steamwar/bungeecore/bot/listeners/PrivateMessageListener.java +++ b/src/de/steamwar/bungeecore/bot/listeners/PrivateMessageListener.java @@ -23,15 +23,20 @@ import de.steamwar.bungeecore.sql.Punishment; import de.steamwar.bungeecore.sql.SchematicNode; import de.steamwar.bungeecore.sql.SteamwarUser; import net.dv8tion.jda.api.entities.Message; -import net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent; +import net.dv8tion.jda.api.entities.channel.ChannelType; +import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import org.jetbrains.annotations.NotNull; import java.io.InputStream; -import java.util.concurrent.CompletableFuture; public class PrivateMessageListener extends BasicDiscordListener { + @Override - public void onPrivateMessageReceived(PrivateMessageReceivedEvent event) { + public void onMessageReceived(@NotNull MessageReceivedEvent event) { + if(!event.isFromType(ChannelType.PRIVATE)) { + return; + } if(!event.getMessage().getAttachments().isEmpty()) { SteamwarUser user = SteamwarUser.get(event.getAuthor().getIdLong()); if (user == null) { @@ -47,7 +52,7 @@ public class PrivateMessageListener extends BasicDiscordListener { for (Message.Attachment attachment : event.getMessage().getAttachments()) { if(attachment.getFileExtension() == null || (!attachment.getFileExtension().equalsIgnoreCase("schem") && - !attachment.getFileExtension().equalsIgnoreCase("schematic"))) { + !attachment.getFileExtension().equalsIgnoreCase("schematic"))) { event.getMessage().reply("`" + attachment.getFileName() + "` wird ignoriert, da die Datei keine Schematic ist").queue(); continue; } diff --git a/src/de/steamwar/bungeecore/bot/listeners/RolesInteractionButtonListener.java b/src/de/steamwar/bungeecore/bot/listeners/RolesInteractionButtonListener.java index ae0e44de..9e3fc043 100644 --- a/src/de/steamwar/bungeecore/bot/listeners/RolesInteractionButtonListener.java +++ b/src/de/steamwar/bungeecore/bot/listeners/RolesInteractionButtonListener.java @@ -20,16 +20,17 @@ package de.steamwar.bungeecore.bot.listeners; import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig; -import net.dv8tion.jda.api.entities.ChannelType; -import net.dv8tion.jda.api.events.interaction.GenericComponentInteractionCreateEvent; +import net.dv8tion.jda.api.entities.channel.ChannelType; +import net.dv8tion.jda.api.events.interaction.component.GenericComponentInteractionCreateEvent; import net.dv8tion.jda.api.interactions.InteractionType; import org.jetbrains.annotations.NotNull; public class RolesInteractionButtonListener extends BasicDiscordListener { + @Override public void onGenericComponentInteractionCreate(@NotNull GenericComponentInteractionCreateEvent event) { - if(event.getType() == InteractionType.COMPONENT && event.getChannelType() == ChannelType.TEXT && event.getTextChannel().getId().equals(SteamwarDiscordBotConfig.ROLES_CHANNEL) && SteamwarDiscordBotConfig.ROLES.stream().anyMatch(discordRole -> discordRole.getRoleId().equals(event.getComponentId()))) { + if(event.getType() == InteractionType.COMPONENT && event.getChannelType() == ChannelType.TEXT && event.getChannel().getId().equals(SteamwarDiscordBotConfig.ROLES_CHANNEL) && SteamwarDiscordBotConfig.ROLES.stream().anyMatch(discordRole -> discordRole.getRoleId().equals(event.getComponentId()))) { if (event.getMember().getRoles().stream().anyMatch(role -> role.getId().equals(event.getComponentId()))) { event.getGuild().removeRoleFromMember(event.getMember(), event.getGuild().getRoleById(event.getComponentId())).complete(); event.reply(SteamwarDiscordBotConfig.ROLES_REMOVED.replace("%role%", event.getGuild().getRoleById(event.getComponentId()).getAsMention())).setEphemeral(true).queue(); diff --git a/src/de/steamwar/bungeecore/bot/listeners/SlashCommandListener.java b/src/de/steamwar/bungeecore/bot/listeners/SlashCommandListener.java index 565ca442..a797ebda 100644 --- a/src/de/steamwar/bungeecore/bot/listeners/SlashCommandListener.java +++ b/src/de/steamwar/bungeecore/bot/listeners/SlashCommandListener.java @@ -20,13 +20,13 @@ package de.steamwar.bungeecore.bot.listeners; import de.steamwar.bungeecore.bot.SteamwarDiscordBot; -import net.dv8tion.jda.api.events.interaction.SlashCommandEvent; +import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; import org.jetbrains.annotations.NotNull; public class SlashCommandListener extends BasicDiscordListener { @Override - public void onSlashCommand(@NotNull SlashCommandEvent event) { + public void onSlashCommandInteraction(@NotNull SlashCommandInteractionEvent event) { SteamwarDiscordBot.getDiscordCommandMap().get(event.getName()).run(event); } } diff --git a/src/de/steamwar/bungeecore/bot/util/DiscordRolesMessage.java b/src/de/steamwar/bungeecore/bot/util/DiscordRolesMessage.java index 1486debd..a4af440d 100644 --- a/src/de/steamwar/bungeecore/bot/util/DiscordRolesMessage.java +++ b/src/de/steamwar/bungeecore/bot/util/DiscordRolesMessage.java @@ -22,11 +22,12 @@ package de.steamwar.bungeecore.bot.util; import de.steamwar.bungeecore.bot.SteamwarDiscordBot; import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig; import lombok.experimental.UtilityClass; -import net.dv8tion.jda.api.MessageBuilder; import net.dv8tion.jda.api.entities.Message; -import net.dv8tion.jda.api.entities.TextChannel; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; import net.dv8tion.jda.api.interactions.components.ActionRow; -import net.dv8tion.jda.api.interactions.components.Button; +import net.dv8tion.jda.api.interactions.components.buttons.Button; +import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder; +import net.dv8tion.jda.api.utils.messages.MessageEditData; import java.util.ArrayList; import java.util.List; @@ -39,17 +40,17 @@ public class DiscordRolesMessage { TextChannel channel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.ROLES_CHANNEL); assert channel != null; - MessageBuilder builder = new MessageBuilder(); + MessageCreateBuilder builder = new MessageCreateBuilder(); builder.setContent(SteamwarDiscordBotConfig.ROLES_BASE_MESSAGE); List