sxcybot

Discord bot for OSRS based channels
git clone git://git.wimdupont.com/sxcybot.git
Log | Files | Refs | README | LICENSE

commit 4d2018082bb926402ca78288d29721234034455d
parent cfefbcce557df0b1e88fe4978c3c4a5038525371
Author: Wim Dupont <wim@wimdupont.com>
Date:   Mon, 23 May 2022 19:07:32 +0200

update deprecations and versions

Diffstat:
Mpom.xml | 6+++---
Msrc/main/java/com/sxcy/sxcybot/listeners/AdminCommandListener.java | 28++++++++++++++--------------
Msrc/main/java/com/sxcy/sxcybot/listeners/CommandListener.java | 61+++++++++++++++++--------------------------------------------
Msrc/main/java/com/sxcy/sxcybot/listeners/PollReactionListener.java | 6+++---
Msrc/main/java/com/sxcy/sxcybot/listeners/admin/BanlistListener.java | 2+-
Msrc/main/java/com/sxcy/sxcybot/listeners/admin/RoleAssignListener.java | 7+++----
Msrc/main/java/com/sxcy/sxcybot/listeners/admin/banlist/UpdateBanlistUserListener.java | 2+-
Msrc/main/java/com/sxcy/sxcybot/listeners/admin/pvmrole/AddPvmListener.java | 2+-
Msrc/main/java/com/sxcy/sxcybot/listeners/admin/pvmrole/UpdatePvmListener.java | 9++++-----
Msrc/main/java/com/sxcy/sxcybot/listeners/admin/role/DeleteRoleListener.java | 4+---
Msrc/main/java/com/sxcy/sxcybot/listeners/admin/rule/DeleteRuleListener.java | 4+---
Msrc/main/java/com/sxcy/sxcybot/listeners/member/CombatStatsListener.java | 5++---
Msrc/main/java/com/sxcy/sxcybot/listeners/member/ForumListener.java | 2+-
Msrc/main/java/com/sxcy/sxcybot/listeners/member/HelpListener.java | 4++--
Msrc/main/java/com/sxcy/sxcybot/listeners/member/HiscoreBossListener.java | 4++--
Msrc/main/java/com/sxcy/sxcybot/listeners/member/KillCountListener.java | 4++--
Msrc/main/java/com/sxcy/sxcybot/listeners/member/PollListener.java | 2+-
Msrc/main/java/com/sxcy/sxcybot/listeners/member/PriceListener.java | 2+-
Msrc/main/java/com/sxcy/sxcybot/listeners/member/PvmListListener.java | 2+-
Msrc/main/java/com/sxcy/sxcybot/listeners/member/RuleListener.java | 2+-
Msrc/main/java/com/sxcy/sxcybot/listeners/member/RulesListener.java | 2+-
Msrc/main/java/com/sxcy/sxcybot/services/PvMRoleResolver.java | 4+---
Msrc/main/java/com/sxcy/sxcybot/services/guild/pvmrole/impl/PvmRoleAssignerServiceImpl.java | 4++--
Msrc/main/java/com/sxcy/sxcybot/services/osrs/impl/StatMessageSenderImpl.java | 2+-
Msrc/main/java/com/sxcy/sxcybot/util/CustomPollFiller.java | 6+++---
Msrc/main/java/com/sxcy/sxcybot/util/DiscordMemberFinderUtil.java | 4++--
Msrc/main/java/com/sxcy/sxcybot/util/EditListenerUtil.java | 2+-
Msrc/main/java/com/sxcy/sxcybot/util/ReleaseNotesUtil.java | 2+-
28 files changed, 74 insertions(+), 110 deletions(-)

diff --git a/pom.xml b/pom.xml @@ -5,7 +5,7 @@ <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> - <version>2.6.3</version> + <version>2.7.0</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>com.sxcy</groupId> @@ -57,8 +57,8 @@ </dependency> <dependency> <groupId>org.flywaydb</groupId> - <artifactId>flyway-maven-plugin</artifactId> - <version>8.4.1</version> + <artifactId>flyway-mysql</artifactId> + <version>8.5.11</version> </dependency> </dependencies> diff --git a/src/main/java/com/sxcy/sxcybot/listeners/AdminCommandListener.java b/src/main/java/com/sxcy/sxcybot/listeners/AdminCommandListener.java @@ -61,32 +61,32 @@ public class AdminCommandListener extends ListenerAdapter { Stream<Role> roleStream = event.getMember().getRoles().stream(); try { switch (adminCommand.get()) { - case EDITRULE: + case EDITRULE -> { isPrivileged(roleStream, event, ADMIN_ROLE); editRuleListener.proces(event); - break; - case EDITBANLIST: + } + case EDITBANLIST -> { isPrivileged(roleStream, event, ADMIN_ROLE); editBanlistListener.proces(event); - break; - case ROLE: + } + case ROLE -> { isPrivileged(roleStream, event, SUB_ADMIN); roleAssignListener.proces(event); - break; - case BANLIST: + } + case BANLIST -> { isPrivileged(roleStream, event, STAFF_ROLE); banlistListener.proces(event); - break; - case EDITROLE: + } + case EDITROLE -> { isPrivileged(roleStream, event, GOD); editRoleListener.proces(event); - break; - case EDITPVM: + } + case EDITPVM -> { isPrivileged(roleStream, event, STAFF_ROLE); editPvmListener.proces(event); - break; - default: - break; + } + default -> { + } } } catch (InsufficientPrivilegesException e) { event.getChannel().sendMessage(e.getMessage()).queue(); diff --git a/src/main/java/com/sxcy/sxcybot/listeners/CommandListener.java b/src/main/java/com/sxcy/sxcybot/listeners/CommandListener.java @@ -72,53 +72,26 @@ public class CommandListener extends ListenerAdapter { Optional<Command> command = messageToCommand(msg); if (command.isPresent()) { switch (command.get()) { - case RULE: - ruleListener.proces(event); - break; - case RULES: - rulesListener.proces(event); - break; - case PING: - pingListener.proces(event); - break; + case RULE -> ruleListener.proces(event); + case RULES -> rulesListener.proces(event); + case PING -> pingListener.proces(event); + // case EVENT: // eventListener.proces(event); // break; - case CBSTATS: - combatStatsListener.proces(event); - break; - case STATS: - statsListener.proces(event); - break; - case PRICE: - priceListener.proces(event); - break; - case FORUM: - forumListener.proces(event); - break; - case POLL: - pollListener.proces(event); - break; - case CPOLL: - customPollListener.proces(event); - break; - case KC: - killCountListener.proces(event); - break; - case PVMLIST: - pvmListListener.proces(event); - break; - case BOSSLIST: - hiscoreBossListener.proces(event); - break; - case PVMCHECK: - pvmRoleCheckListener.proces(event); - break; - case HELP: - helpListener.proces(event); - break; - default: - break; + case CBSTATS -> combatStatsListener.proces(event); + case STATS -> statsListener.proces(event); + case PRICE -> priceListener.proces(event); + case FORUM -> forumListener.proces(event); + case POLL -> pollListener.proces(event); + case CPOLL -> customPollListener.proces(event); + case KC -> killCountListener.proces(event); + case PVMLIST -> pvmListListener.proces(event); + case BOSSLIST -> hiscoreBossListener.proces(event); + case PVMCHECK -> pvmRoleCheckListener.proces(event); + case HELP -> helpListener.proces(event); + default -> { + } } } else if (Commands.BB8.equals(msg)) { bb8Listener.proces(event); diff --git a/src/main/java/com/sxcy/sxcybot/listeners/PollReactionListener.java b/src/main/java/com/sxcy/sxcybot/listeners/PollReactionListener.java @@ -54,7 +54,7 @@ public class PollReactionListener extends ListenerAdapter { } } } - message.editMessage(embedBuilder.build()).queue(); + message.editMessageEmbeds(embedBuilder.build()).queue(); message.removeReaction(event.getReaction().getReactionEmote().getEmoji(), event.getUser()).queue(); } }); @@ -91,11 +91,11 @@ public class PollReactionListener extends ListenerAdapter { // embedBuilder.getFields() // .set(messageEmbed.getFields().indexOf(field), // new Field(field.getName(), field.getValue().replace(user.getName(), ""), field.isInline())); -// message.editMessage(embedBuilder.build()).queue(); +// message.editMessageEmbeds(embedBuilder.build()).queue(); // } // } // } -// message.editMessage(embedBuilder.build()).queue(); +// message.editMessageEmbeds(embedBuilder.build()).queue(); // } // }); // } diff --git a/src/main/java/com/sxcy/sxcybot/listeners/admin/BanlistListener.java b/src/main/java/com/sxcy/sxcybot/listeners/admin/BanlistListener.java @@ -43,7 +43,7 @@ public class BanlistListener implements Listener { false); if (JdaUtil.requiresBuild(embedBuilder, bannedList.size(), i)) { - privateChannel.sendMessage(embedBuilder.build()).queue(); + privateChannel.sendMessageEmbeds(embedBuilder.build()).queue(); embedBuilder.clear(); } i++; diff --git a/src/main/java/com/sxcy/sxcybot/listeners/admin/RoleAssignListener.java b/src/main/java/com/sxcy/sxcybot/listeners/admin/RoleAssignListener.java @@ -19,7 +19,6 @@ import java.awt.Color; import java.util.Comparator; import java.util.List; import java.util.Optional; -import java.util.stream.Collectors; import static com.sxcy.sxcybot.util.Constants.ADDED_ROLE_ELEVATION; @@ -49,11 +48,11 @@ public class RoleAssignListener implements Listener { embedBuilder.clearFields(); embedBuilder.setTitle("Type the number of the role to add, if the member already has this role it will get removed instead."); List<GuildRole> rolesToAdd = guildRoleService.findAllByElevationGreaterThanEqual(ADDED_ROLE_ELEVATION) - .stream().sorted(Comparator.nullsLast(Comparator.comparing(GuildRole::getOrderValue))).collect(Collectors.toList()); + .stream().sorted(Comparator.nullsLast(Comparator.comparing(GuildRole::getOrderValue))).toList(); for (GuildRole guildRole : rolesToAdd) { embedBuilder.addField(String.valueOf(guildRole.getOrderValue()), String.valueOf(guildRole.getName()), true); } - privateChannel.sendMessage(embedBuilder.build()).queue(); + privateChannel.sendMessageEmbeds(embedBuilder.build()).queue(); eventWaiterUtil.waitForPrivateChannelEvent(roleReceiver -> { String roleMessage = roleReceiver.getMessage().getContentRaw(); try { @@ -72,7 +71,7 @@ public class RoleAssignListener implements Listener { } embedBuilder.clearFields(); embedBuilder.addField(String.format("Role has been succesfully %s.", action), "", false); - privateChannel.sendMessage(embedBuilder.build()).queue(); + privateChannel.sendMessageEmbeds(embedBuilder.build()).queue(); event.getChannel().sendMessage(String.format("Role \"%s\" has been %s to %s by %s", role.get().getName(), action, member.getUser(), event.getMember().getUser().getName())).queue(); } else { diff --git a/src/main/java/com/sxcy/sxcybot/listeners/admin/banlist/UpdateBanlistUserListener.java b/src/main/java/com/sxcy/sxcybot/listeners/admin/banlist/UpdateBanlistUserListener.java @@ -36,7 +36,7 @@ public class UpdateBanlistUserListener implements PrivateListener { embedBuilder.setTitle("Banned users:"); userService.findAllBanned().stream().map(User::getName).toList().forEach(f -> embedBuilder.addField(f, "", false)); - privateChannel.sendMessage(embedBuilder.build()).queue(); + privateChannel.sendMessageEmbeds(embedBuilder.build()).queue(); this.proces(privateMessageReceivedEvent, event); return; } diff --git a/src/main/java/com/sxcy/sxcybot/listeners/admin/pvmrole/AddPvmListener.java b/src/main/java/com/sxcy/sxcybot/listeners/admin/pvmrole/AddPvmListener.java @@ -41,7 +41,7 @@ public class AddPvmListener implements PrivateListener { discordMemberFinderUtil.onMemberFoundVerification(event, embedBuilder, privateChannel, member -> { embedBuilder.clearFields(); embedBuilder.addField("Type the RSN (RuneScape name) of the member.", "", true); - privateChannel.sendMessage(embedBuilder.build()).queue(); + privateChannel.sendMessageEmbeds(embedBuilder.build()).queue(); eventWaiterUtil.waitForPrivateChannelEvent((rsnReceiver) -> { String creator = JdaUtil.getName(event); try { diff --git a/src/main/java/com/sxcy/sxcybot/listeners/admin/pvmrole/UpdatePvmListener.java b/src/main/java/com/sxcy/sxcybot/listeners/admin/pvmrole/UpdatePvmListener.java @@ -36,7 +36,7 @@ public class UpdatePvmListener implements PrivateListener { embedBuilder.setColor(Color.RED); embedBuilder.setTitle("Update user for PvM competition."); embedBuilder.addField("Type the discord name of the user you want to update.", "", false); - privateChannel.sendMessage(embedBuilder.build()).queue(); + privateChannel.sendMessageEmbeds(embedBuilder.build()).queue(); embedBuilder.clearFields(); eventWaiterUtil.waitForPrivateChannelEvent(discordNameReceiver -> { String discordName = discordNameReceiver.getMessage().getContentRaw(); @@ -45,13 +45,13 @@ public class UpdatePvmListener implements PrivateListener { embedBuilder.addField("Confirm by typing ``yes or y``.", String.format("Is " + System.lineSeparator() + "Discord: %s | RSN: %s " + System.lineSeparator() + "the correct member?" , oldPvmRoleUser.getDiscordName(), oldPvmRoleUser.getRsn()), false); - privateChannel.sendMessage(embedBuilder.build()).queue(); + privateChannel.sendMessageEmbeds(embedBuilder.build()).queue(); embedBuilder.clearFields(); eventWaiterUtil.waitForPrivateChannelEvent(memberVerifyReceiver -> { String verifyMessage = memberVerifyReceiver.getMessage().getContentRaw(); if ("y".equalsIgnoreCase(verifyMessage) || "yes".equalsIgnoreCase(verifyMessage)) { embedBuilder.addField("Type the new RSN for the update.", "", false); - privateChannel.sendMessage(embedBuilder.build()).queue(); + privateChannel.sendMessageEmbeds(embedBuilder.build()).queue(); embedBuilder.clearFields(); eventWaiterUtil.waitForPrivateChannelEvent(newRsnReceiver -> { String newRsn = newRsnReceiver.getMessage().getContentRaw(); @@ -78,4 +78,4 @@ public class UpdatePvmListener implements PrivateListener { } }, privateMessageReceivedEvent, privateChannel); } -} -\ No newline at end of file +} diff --git a/src/main/java/com/sxcy/sxcybot/listeners/admin/role/DeleteRoleListener.java b/src/main/java/com/sxcy/sxcybot/listeners/admin/role/DeleteRoleListener.java @@ -13,8 +13,6 @@ import net.dv8tion.jda.api.events.message.MessageReceivedEvent; import net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent; import org.springframework.stereotype.Component; -import java.util.stream.Collectors; - import static com.sxcy.sxcybot.util.Constants.ADDED_ROLE_ELEVATION; import static com.sxcy.sxcybot.util.Constants.Commands.COMMAND_PREFIX; @@ -36,7 +34,7 @@ public class DeleteRoleListener implements PrivateListener { GuildRole guildRole = guildRoleService.findByName(nameReceiver.getMessage().getContentRaw()); if (guildRole.getElevation() == ADDED_ROLE_ELEVATION){ guildRoleService.delete(guildRole); - guildRoleService.findAll().stream().filter(f -> f.getOrderValue() != null && f.getOrderValue() > guildRole.getOrderValue()).collect(Collectors.toList()) + guildRoleService.findAll().stream().filter(f -> f.getOrderValue() != null && f.getOrderValue() > guildRole.getOrderValue()).toList() .forEach(f -> guildRoleService.save(f.toBuilder().orderValue(f.getOrderValue() - 1).build())); privateChannel.sendMessage(String.format("%s succesfully deleted.", guildRole)).queue(); event.getChannel().sendMessage(String.format("Role %s has been deleted by %s", guildRole, JdaUtil.getUser(event))).queue(); diff --git a/src/main/java/com/sxcy/sxcybot/listeners/admin/rule/DeleteRuleListener.java b/src/main/java/com/sxcy/sxcybot/listeners/admin/rule/DeleteRuleListener.java @@ -13,8 +13,6 @@ import net.dv8tion.jda.api.events.message.MessageReceivedEvent; import net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent; import org.springframework.stereotype.Component; -import java.util.stream.Collectors; - @Component @RequiredArgsConstructor @@ -34,7 +32,7 @@ public class DeleteRuleListener implements PrivateListener { int ruleNumber = Integer.parseInt(ruleDeleltionReceiver.getMessage().getContentRaw()); Rule rule = ruleService.findByNumber(ruleNumber); ruleService.delete(rule); - ruleService.findAll().stream().filter(f -> f.getNumber() > ruleNumber).collect(Collectors.toList()) + ruleService.findAll().stream().filter(f -> f.getNumber() > ruleNumber).toList() .forEach(f -> ruleService.save(f.toBuilder().number(f.getNumber() - 1).build())); privateChannel.sendMessage(String.format("%s has been succesfully deleted.", rule)).queue(); event.getChannel().sendMessage(String.format("Rule %s has been deleted by %s", rule, JdaUtil.getUser(event))).queue(); diff --git a/src/main/java/com/sxcy/sxcybot/listeners/member/CombatStatsListener.java b/src/main/java/com/sxcy/sxcybot/listeners/member/CombatStatsListener.java @@ -11,7 +11,7 @@ import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.events.message.MessageReceivedEvent; import org.springframework.stereotype.Component; -import java.util.ArrayList; +import java.util.List; import static com.sxcy.sxcybot.enums.OsrsCombatStat.ATTACK; import static com.sxcy.sxcybot.enums.OsrsCombatStat.DEFENCE; @@ -20,7 +20,6 @@ import static com.sxcy.sxcybot.enums.OsrsCombatStat.MAGIC; import static com.sxcy.sxcybot.enums.OsrsCombatStat.PRAYER; import static com.sxcy.sxcybot.enums.OsrsCombatStat.RANGED; import static com.sxcy.sxcybot.enums.OsrsCombatStat.STRENGTH; -import static com.google.common.collect.Lists.newArrayList; @Component @RequiredArgsConstructor @@ -31,7 +30,7 @@ public class CombatStatsListener implements Listener { @NonNull private final CombatCalculatorService combatCalculatorService; - private static final ArrayList<String> COMBAT_STAT_LIST = newArrayList(ATTACK.value, STRENGTH.value, DEFENCE.value, HITPOINTS.value, RANGED.value, PRAYER.value, MAGIC.value); + private static final List<String> COMBAT_STAT_LIST = List.of(ATTACK.value, STRENGTH.value, DEFENCE.value, HITPOINTS.value, RANGED.value, PRAYER.value, MAGIC.value); @Override public void proces(MessageReceivedEvent event) { diff --git a/src/main/java/com/sxcy/sxcybot/listeners/member/ForumListener.java b/src/main/java/com/sxcy/sxcybot/listeners/member/ForumListener.java @@ -25,7 +25,7 @@ public class ForumListener implements Listener { EmbedBuilder embedBuilder = new EmbedBuilder(); embedBuilder.setColor(Color.RED); embedBuilder.setTitle("Link to the forum post", channelDetail.getForumUrl()); - channel.sendMessage(embedBuilder.build()).queue(); + channel.sendMessageEmbeds(embedBuilder.build()).queue(); }); } } diff --git a/src/main/java/com/sxcy/sxcybot/listeners/member/HelpListener.java b/src/main/java/com/sxcy/sxcybot/listeners/member/HelpListener.java @@ -29,7 +29,7 @@ public class HelpListener implements Listener { for (Admin admin : Admin.values()) { adminEmbedBuilder.addField(Commands.COMMAND_PREFIX + admin.name().toLowerCase(), admin.description, false); } - event.getChannel().sendMessage(embedBuilder.build()).queue(); - event.getChannel().sendMessage(adminEmbedBuilder.build()).queue(); + event.getChannel().sendMessageEmbeds(embedBuilder.build()).queue(); + event.getChannel().sendMessageEmbeds(adminEmbedBuilder.build()).queue(); } } diff --git a/src/main/java/com/sxcy/sxcybot/listeners/member/HiscoreBossListener.java b/src/main/java/com/sxcy/sxcybot/listeners/member/HiscoreBossListener.java @@ -36,14 +36,14 @@ public class HiscoreBossListener implements Listener { osrsHiscoreBoss.getMultiplier()), true); if (JdaUtil.requiresBuild(embedBuilder, hiscoreBossList.size(), i)) { - event.getChannel().sendMessage(embedBuilder.build()).queue(); + event.getChannel().sendMessageEmbeds(embedBuilder.build()).queue(); embedBuilder.clearFields(); } } i++; } if (embedBuilder.getFields().size() > 0) - event.getChannel().sendMessage(embedBuilder.build()).queue(); + event.getChannel().sendMessageEmbeds(embedBuilder.build()).queue(); embedBuilder.clearFields(); } } diff --git a/src/main/java/com/sxcy/sxcybot/listeners/member/KillCountListener.java b/src/main/java/com/sxcy/sxcybot/listeners/member/KillCountListener.java @@ -36,11 +36,11 @@ public class KillCountListener implements Listener { bossKcList.stream().filter(f -> !"-1".equals(f.getKc())).forEach(f -> { embedBuilder.addField(f.getName(), String.format("Kc: %s%sRank: %s", f.getKc(), System.lineSeparator(), f.getRank()), true); if (JdaUtil.requiresBuild(embedBuilder, bossKcList.size(), i)) { - event.getChannel().sendMessage(embedBuilder.build()).queue(); + event.getChannel().sendMessageEmbeds(embedBuilder.build()).queue(); embedBuilder.clearFields(); } }); - event.getChannel().sendMessage(embedBuilder.build()).queue(); + event.getChannel().sendMessageEmbeds(embedBuilder.build()).queue(); }); } catch (StringIndexOutOfBoundsException e) { diff --git a/src/main/java/com/sxcy/sxcybot/listeners/member/PollListener.java b/src/main/java/com/sxcy/sxcybot/listeners/member/PollListener.java @@ -34,7 +34,7 @@ public class PollListener implements Listener { embedBuilder.setFooter("Let the polling begin!", event.getGuild().getIconUrl()); event.getChannel().sendTyping().queue(typing -> - event.getChannel().sendMessage(embedBuilder.build()).queue(message -> { + event.getChannel().sendMessageEmbeds(embedBuilder.build()).queue(message -> { message.addReaction(Reaction.CHECK_MARK_BUTTON) .and(message.addReaction(Reaction.CROSS_MARK_BUTTON)) .and(message.addReaction(Reaction.QUESTION_MARK)) diff --git a/src/main/java/com/sxcy/sxcybot/listeners/member/PriceListener.java b/src/main/java/com/sxcy/sxcybot/listeners/member/PriceListener.java @@ -30,7 +30,7 @@ public class PriceListener implements Listener { embedBuilder.setTitle("Price of item"); embedBuilder.setColor(Color.RED); embedBuilder.addField(itemName, result, false); - event.getChannel().sendMessage(embedBuilder.build()).queue(); + event.getChannel().sendMessageEmbeds(embedBuilder.build()).queue(); } catch (EntityNotFoundException e) { event.getChannel().sendMessage(e.getMessage()).queue(); } diff --git a/src/main/java/com/sxcy/sxcybot/listeners/member/PvmListListener.java b/src/main/java/com/sxcy/sxcybot/listeners/member/PvmListListener.java @@ -34,7 +34,7 @@ public class PvmListListener implements Listener { pvmRoleUser.getCreatedBy(), pvmRoleUser.getCreatedDate(), pvmRoleUser.getLastModifiedBy(), pvmRoleUser.getLastModifiedDate()), false); if (JdaUtil.requiresBuild(embedBuilder, pvmRoleUsers.size(), i)) { - event.getChannel().sendMessage(embedBuilder.build()).queue(); + event.getChannel().sendMessageEmbeds(embedBuilder.build()).queue(); embedBuilder.clear(); } i++; diff --git a/src/main/java/com/sxcy/sxcybot/listeners/member/RuleListener.java b/src/main/java/com/sxcy/sxcybot/listeners/member/RuleListener.java @@ -39,7 +39,7 @@ public class RuleListener implements Listener { embedBuilder.setColor(Color.RED); embedBuilder.setTitle("Show rule result"); embedBuilder.addField(String.format("Rule #%s", ruleNumber), description, false); - channel.sendMessage(embedBuilder.build()).queue(); + channel.sendMessageEmbeds(embedBuilder.build()).queue(); } } diff --git a/src/main/java/com/sxcy/sxcybot/listeners/member/RulesListener.java b/src/main/java/com/sxcy/sxcybot/listeners/member/RulesListener.java @@ -32,7 +32,7 @@ public class RulesListener implements Listener { for (Rule rule : ruleList) { embedBuilder.addField(String.format("Rule #%s", rule.getNumber()), rule.getDescription(), false); if (JdaUtil.requiresBuild(embedBuilder, ruleList.size(), i)) { - event.getChannel().sendMessage(embedBuilder.build()).queue(); + event.getChannel().sendMessageEmbeds(embedBuilder.build()).queue(); embedBuilder.clear(); } i++; diff --git a/src/main/java/com/sxcy/sxcybot/services/PvMRoleResolver.java b/src/main/java/com/sxcy/sxcybot/services/PvMRoleResolver.java @@ -24,8 +24,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import static com.google.common.collect.Lists.newArrayList; - @Slf4j @Component @RequiredArgsConstructor @@ -57,7 +55,7 @@ public class PvMRoleResolver { } jda.getGuilds().forEach(guild -> channelDetailService.findAll().stream().findAny().ifPresent(channelDetail -> - (privateChannel == null ? guild.getTextChannelsByName(channelDetail.getPvmRoleChannel(), true) : newArrayList(privateChannel)) + (privateChannel == null ? guild.getTextChannelsByName(channelDetail.getPvmRoleChannel(), true) : List.of(privateChannel)) .forEach(textChannel -> { for (PvmRoleUser pvmRoleUser : pvmRoleUserService.findAll()) { List<PvmKcSnapshot> pvmKcSnapshots = new ArrayList<>(); diff --git a/src/main/java/com/sxcy/sxcybot/services/guild/pvmrole/impl/PvmRoleAssignerServiceImpl.java b/src/main/java/com/sxcy/sxcybot/services/guild/pvmrole/impl/PvmRoleAssignerServiceImpl.java @@ -36,7 +36,7 @@ public class PvmRoleAssignerServiceImpl implements PvmRoleAssignerService { embedBuilder.setTitle(String.format("**%s** Scoreboard results:", rolename)); if (scoreBoard.get(pvmRole).isEmpty()) { embedBuilder.addField(String.format("No KC gains detected for %s", pvmRole.name().toLowerCase()), "No increase in KC found for participants, role will remain unchanged.", false); - textChannel.sendMessage(embedBuilder.build()).queue(); + textChannel.sendMessageEmbeds(embedBuilder.build()).queue(); continue; } List<Map.Entry<PvmRoleUser, BigDecimal>> entries = new ArrayList<>(scoreBoard.get(pvmRole).entrySet()); @@ -75,7 +75,7 @@ public class PvmRoleAssignerServiceImpl implements PvmRoleAssignerService { } i++; } - textChannel.sendMessage(embedBuilder.build()).queue(); + textChannel.sendMessageEmbeds(embedBuilder.build()).queue(); }); } } diff --git a/src/main/java/com/sxcy/sxcybot/services/osrs/impl/StatMessageSenderImpl.java b/src/main/java/com/sxcy/sxcybot/services/osrs/impl/StatMessageSenderImpl.java @@ -39,7 +39,7 @@ public class StatMessageSenderImpl implements StatMessageSender { if (calcCombatLevel != null) { calcCombatLevel.accept(osrsStatList); } - event.getChannel().sendMessage(embedBuilder.build()).queue(); + event.getChannel().sendMessageEmbeds(embedBuilder.build()).queue(); } catch (EntityNotFoundException entityNotFoundException) { event.getChannel().sendMessage(entityNotFoundException.getMessage()).queue(); } diff --git a/src/main/java/com/sxcy/sxcybot/util/CustomPollFiller.java b/src/main/java/com/sxcy/sxcybot/util/CustomPollFiller.java @@ -33,12 +33,12 @@ public class CustomPollFiller { EmbedBuilder embeddedOption = new EmbedBuilder(); embeddedOption.setColor(Color.RED); embeddedOption.addField("Please enter an option for the poll", "`stop` to finish and create the poll.", false); - privateChannel.sendMessage(embeddedOption.build()).queue(); + privateChannel.sendMessageEmbeds(embeddedOption.build()).queue(); embeddedOption.clear(); eventWaiterUtil.waitForPrivateChannelEvent(optionReceiver -> { if (isReadyToStop(optionReceiver)) { event.getChannel().sendTyping().queue(typing -> - event.getChannel().sendMessage(embedBuilder.build()).queue(message -> { + event.getChannel().sendMessageEmbeds(embedBuilder.build()).queue(message -> { emojiList.forEach(emoji -> message.addReaction(emoji).queue()); pollService.save(Poll.builder().messageId(message.getId()).build()); })); @@ -46,7 +46,7 @@ public class CustomPollFiller { } embeddedOption.setColor(Color.RED); embeddedOption.addField(String.format("Please type in a reaction emoji for _%s_.", optionReceiver.getMessage().getContentRaw()), "", false); - privateChannel.sendMessage(embeddedOption.build()).queue(); + privateChannel.sendMessageEmbeds(embeddedOption.build()).queue(); embeddedOption.clear(); eventWaiterUtil.waitForPrivateChannelEvent(emojiReceiver -> { if (!emojiList.contains(emojiReceiver.getMessage().getContentRaw())) { diff --git a/src/main/java/com/sxcy/sxcybot/util/DiscordMemberFinderUtil.java b/src/main/java/com/sxcy/sxcybot/util/DiscordMemberFinderUtil.java @@ -21,7 +21,7 @@ public class DiscordMemberFinderUtil { public void onMemberFoundVerification(MessageReceivedEvent event, EmbedBuilder embedBuilder, PrivateChannel privateChannel, Consumer<Member> memberConsumer) { embedBuilder.addField("Type the name of the user.", "Discord username will be looked up first, if no match is found it will search on nickname.", false); - privateChannel.sendMessage(embedBuilder.build()).queue(); + privateChannel.sendMessageEmbeds(embedBuilder.build()).queue(); eventWaiterUtil.waitForPrivateChannelEvent(memberReceiver -> { String name = memberReceiver.getMessage().getContentRaw(); event.getGuild().loadMembers().onSuccess(memberList -> { @@ -32,7 +32,7 @@ public class DiscordMemberFinderUtil { if (member.isPresent()) { embedBuilder.clearFields(); embedBuilder.addField("Confirm by typing ``yes or y``.", String.format("Is %s the correct member?", member.get()), false); - privateChannel.sendMessage(embedBuilder.build()).queue(); + privateChannel.sendMessageEmbeds(embedBuilder.build()).queue(); eventWaiterUtil.waitForPrivateChannelEvent(memberVerifyReceiver -> { String verifyMessage = memberVerifyReceiver.getMessage().getContentRaw(); if ("y".equalsIgnoreCase(verifyMessage) || "yes".equalsIgnoreCase(verifyMessage)) { diff --git a/src/main/java/com/sxcy/sxcybot/util/EditListenerUtil.java b/src/main/java/com/sxcy/sxcybot/util/EditListenerUtil.java @@ -24,7 +24,7 @@ public class EditListenerUtil { embedBuilder.addField("2", String.format("Delete an existing %s.", editListenerDto.getEntityName()), false); if (editListenerDto.getUpdateListener() != null) embedBuilder.addField("3", String.format("Update an existing %s.", editListenerDto.getEntityName()), false); - editListenerDto.getPrivateChannel().sendMessage(embedBuilder.build()).queue(); + editListenerDto.getPrivateChannel().sendMessageEmbeds(embedBuilder.build()).queue(); eventWaiterUtil.waitForPrivateChannelEvent(commandReceiver -> { switch (commandReceiver.getMessage().getContentRaw()) { case "1": diff --git a/src/main/java/com/sxcy/sxcybot/util/ReleaseNotesUtil.java b/src/main/java/com/sxcy/sxcybot/util/ReleaseNotesUtil.java @@ -42,7 +42,7 @@ public class ReleaseNotesUtil { channelDetailService.findAll().stream().findAny() .ifPresent(detail -> jda.getTextChannelsByName(detail.getBotUpdateChannel(), false).forEach(f -> - f.sendMessage(embedBuilder.build()).queue() + f.sendMessageEmbeds(embedBuilder.build()).queue() )); } }