From d4fdc8af58e0e8de2eccfb3fc8d1826acf3b64c4 Mon Sep 17 00:00:00 2001 From: benaclejames Date: Mon, 10 Jun 2024 23:03:01 +0100 Subject: [PATCH] housekeeping, updates, and log stuff --- pom.xml | 28 +++++++++---------- .../gumcord/Commands/LicenseVerifier.java | 4 +-- .../gumcord/Interactions/ButtonHandler.java | 3 +- .../Interactions/InteractionHandler.java | 20 ++++++------- .../Interactions/Modal/VerifyModal.java | 9 +++--- .../SelectMenu/PaginatedSelectMenu.java | 4 +-- .../benaclejames/gumcord/SetupHandler.java | 10 +++---- .../gumcord/Utils/AdminChannel.java | 4 +-- src/main/resources/logback.xml | 12 ++++++++ 9 files changed, 51 insertions(+), 43 deletions(-) create mode 100644 src/main/resources/logback.xml diff --git a/pom.xml b/pom.xml index ef167bb..747f0a9 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ com.amazonaws aws-java-sdk-bom - 1.12.372 + 1.12.739 pom import @@ -27,22 +27,28 @@ com.fasterxml.jackson.core jackson-annotations - 2.12.3 + 2.17.1 com.fasterxml.jackson.core jackson-core - 2.12.3 + 2.17.1 net.dv8tion JDA - 5.0.0-alpha.18 + 5.0.0-beta.24 + + + club.minnced + opus-java + + - org.bouncycastle - bcpkix-jdk15on - 1.70 + ch.qos.logback + logback-classic + 1.5.6 com.google.code.gson @@ -51,14 +57,6 @@ - - - dv8tion - m2-dv8tion - https://m2.dv8tion.net/releases - - - 11 11 diff --git a/src/main/java/com/benaclejames/gumcord/Commands/LicenseVerifier.java b/src/main/java/com/benaclejames/gumcord/Commands/LicenseVerifier.java index 28f6f4b..884e230 100644 --- a/src/main/java/com/benaclejames/gumcord/Commands/LicenseVerifier.java +++ b/src/main/java/com/benaclejames/gumcord/Commands/LicenseVerifier.java @@ -27,14 +27,14 @@ private static void PrintError(IReplyCallback reply, String errorText, String ad } private static String ConstructUserIdentifier(User user) { - return "```" + user.getName() + "#" + user.getDiscriminator() + "```"; + return "```" + user.getName() + "```"; } public static void VerifyLicense(IReplyCallback msg, String gumroadIdOrAlias, String token, GumServer guild) { // Print our debug info System.out.println("GuildID: " + guild.guild.getId()); - System.out.println("User: " + msg.getUser().getName() + "#" + msg.getUser().getDiscriminator()); + System.out.println("User: " + msg.getUser().getName()); System.out.println("Verifying license for " + gumroadIdOrAlias + " with token " + token); // Check if we have an applicable alias diff --git a/src/main/java/com/benaclejames/gumcord/Interactions/ButtonHandler.java b/src/main/java/com/benaclejames/gumcord/Interactions/ButtonHandler.java index 59c452e..9b21797 100644 --- a/src/main/java/com/benaclejames/gumcord/Interactions/ButtonHandler.java +++ b/src/main/java/com/benaclejames/gumcord/Interactions/ButtonHandler.java @@ -7,12 +7,11 @@ import net.dv8tion.jda.api.events.interaction.component.ButtonInteractionEvent; import net.dv8tion.jda.api.hooks.ListenerAdapter; -import javax.annotation.Nonnull; import java.util.List; public class ButtonHandler extends ListenerAdapter { @Override - public void onButtonInteraction(@Nonnull ButtonInteractionEvent event) { + public void onButtonInteraction(ButtonInteractionEvent event) { // Ensure the button clicked has the id "verifybutton" if (!event.getComponentId().equals("verifybutton")) return; diff --git a/src/main/java/com/benaclejames/gumcord/Interactions/InteractionHandler.java b/src/main/java/com/benaclejames/gumcord/Interactions/InteractionHandler.java index 23c8357..899c1f0 100644 --- a/src/main/java/com/benaclejames/gumcord/Interactions/InteractionHandler.java +++ b/src/main/java/com/benaclejames/gumcord/Interactions/InteractionHandler.java @@ -13,16 +13,16 @@ import net.dv8tion.jda.api.entities.Role; import net.dv8tion.jda.api.events.interaction.ModalInteractionEvent; import net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent; -import net.dv8tion.jda.api.events.interaction.component.SelectMenuInteractionEvent; + +import net.dv8tion.jda.api.events.interaction.component.StringSelectInteractionEvent; import net.dv8tion.jda.api.hooks.ListenerAdapter; import net.dv8tion.jda.api.interactions.components.ActionRow; -import net.dv8tion.jda.api.interactions.components.Modal; import net.dv8tion.jda.api.interactions.components.buttons.Button; -import net.dv8tion.jda.api.interactions.components.selections.SelectMenu; +import net.dv8tion.jda.api.interactions.components.selections.StringSelectMenu; import net.dv8tion.jda.api.interactions.components.text.TextInput; import net.dv8tion.jda.api.interactions.components.text.TextInputStyle; +import net.dv8tion.jda.api.interactions.modals.Modal; -import javax.annotation.Nonnull; import java.awt.*; import java.util.ArrayList; import java.util.HashSet; @@ -31,8 +31,8 @@ public class InteractionHandler extends ListenerAdapter { @Override - public void onSlashCommandInteraction(@Nonnull SlashCommandInteractionEvent event) { - switch (event.getCommandPath()) { + public void onSlashCommandInteraction(SlashCommandInteractionEvent event) { + switch (event.getFullCommandName()) { case "spawnverify": { // Create a button @@ -139,16 +139,16 @@ private Modal createVerifyWindow(String productId, String productName) { .build(); return Modal.create("verifymodal_" + productId, "Verify License Key for " + productName) - .addActionRows(ActionRow.of(subject)) + .addComponents(ActionRow.of(subject)) .build(); } - private String getNameFromIdDropdown(SelectMenu selectDropdown, String id) { + private String getNameFromIdDropdown(StringSelectMenu selectDropdown, String id) { return selectDropdown.getOptions().stream().filter(option -> option.getValue().equals(id)).findFirst().get().getLabel(); } @Override - public void onSelectMenuInteraction(SelectMenuInteractionEvent event) { + public void onStringSelectInteraction(StringSelectInteractionEvent event) { if (!event.getComponentId().startsWith("verifyselector")) return; @@ -159,7 +159,7 @@ public void onSelectMenuInteraction(SelectMenuInteractionEvent event) { } @Override - public void onModalInteraction(@Nonnull ModalInteractionEvent event) { + public void onModalInteraction(ModalInteractionEvent event) { if (event.getModalId().startsWith("verifymodal_")) { String id = event.getModalId().replace("verifymodal_", ""); String licenseKey = event.getValue("key").getAsString(); diff --git a/src/main/java/com/benaclejames/gumcord/Interactions/Modal/VerifyModal.java b/src/main/java/com/benaclejames/gumcord/Interactions/Modal/VerifyModal.java index 4c5abe0..9d0cdfa 100644 --- a/src/main/java/com/benaclejames/gumcord/Interactions/Modal/VerifyModal.java +++ b/src/main/java/com/benaclejames/gumcord/Interactions/Modal/VerifyModal.java @@ -1,11 +1,10 @@ package com.benaclejames.gumcord.Interactions.Modal; import net.dv8tion.jda.api.interactions.components.ActionRow; +import net.dv8tion.jda.api.interactions.components.LayoutComponent; import net.dv8tion.jda.api.interactions.components.text.TextInput; import net.dv8tion.jda.api.interactions.components.text.TextInputStyle; -import net.dv8tion.jda.internal.interactions.component.ModalImpl; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Unmodifiable; +import net.dv8tion.jda.internal.interactions.modal.ModalImpl; import java.util.Collections; import java.util.List; @@ -16,7 +15,7 @@ public VerifyModal(String id, String title) { super("verifymodal_" + id, ComputeTitle(title), ConstructModalComponents()); } - private static String ComputeTitle(@NotNull String productName) { + private static String ComputeTitle(String productName) { String computedName = productName; // If the productname is longer than 45 characters, add an ellipsis @@ -30,7 +29,7 @@ private static String ComputeTitle(@NotNull String productName) { return computedName; } - private static @NotNull @Unmodifiable List ConstructModalComponents() { + private static List ConstructModalComponents() { TextInput subject = TextInput.create("key", "License Key", TextInputStyle.SHORT) .setPlaceholder("12345678-12345678-12345678-12345678") .setRequiredRange(35, 35) diff --git a/src/main/java/com/benaclejames/gumcord/Interactions/SelectMenu/PaginatedSelectMenu.java b/src/main/java/com/benaclejames/gumcord/Interactions/SelectMenu/PaginatedSelectMenu.java index a4ea121..3448856 100644 --- a/src/main/java/com/benaclejames/gumcord/Interactions/SelectMenu/PaginatedSelectMenu.java +++ b/src/main/java/com/benaclejames/gumcord/Interactions/SelectMenu/PaginatedSelectMenu.java @@ -11,7 +11,7 @@ import net.dv8tion.jda.api.interactions.components.ActionRow; import net.dv8tion.jda.api.interactions.components.LayoutComponent; import net.dv8tion.jda.api.interactions.components.buttons.Button; -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.MessageEditBuilder; import org.jetbrains.annotations.NotNull; @@ -55,7 +55,7 @@ public Collection build() { int offset = this.page * 25; // First, fill our list with as many elements as we can before hitting the 25 item limit - SelectMenu.Builder selectMenu = SelectMenu.create(this.id).setMaxValues(1); + StringSelectMenu.Builder selectMenu = StringSelectMenu.create(this.id).setMaxValues(1); int i; for (i = 0; i < Math.min(25, this.items.size() - offset); i++) { diff --git a/src/main/java/com/benaclejames/gumcord/SetupHandler.java b/src/main/java/com/benaclejames/gumcord/SetupHandler.java index b5c224f..a0e3184 100644 --- a/src/main/java/com/benaclejames/gumcord/SetupHandler.java +++ b/src/main/java/com/benaclejames/gumcord/SetupHandler.java @@ -4,7 +4,7 @@ import com.benaclejames.gumcord.Dynamo.TableTypes.GumServer; import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.entities.Guild; -import net.dv8tion.jda.api.events.ReadyEvent; +import net.dv8tion.jda.api.events.session.ReadyEvent; import net.dv8tion.jda.api.events.guild.GuildJoinEvent; import net.dv8tion.jda.api.events.guild.GuildLeaveEvent; import net.dv8tion.jda.api.events.guild.GuildReadyEvent; @@ -14,19 +14,19 @@ import net.dv8tion.jda.api.interactions.commands.OptionType; import net.dv8tion.jda.api.interactions.commands.build.Commands; import net.dv8tion.jda.api.interactions.commands.build.OptionData; +import org.jetbrains.annotations.NotNull; -import javax.annotation.Nonnull; import java.util.Map; public final class SetupHandler extends ListenerAdapter { @Override - public void onGuildJoin(@Nonnull GuildJoinEvent event) { + public void onGuildJoin(GuildJoinEvent event) { DynamoHelper.GetServer(event.getGuild()); System.out.println("Joined " + event.getGuild().getName()); } @Override - public void onGuildLeave(@Nonnull GuildLeaveEvent event) { + public void onGuildLeave(@NotNull GuildLeaveEvent event) { } @@ -86,7 +86,7 @@ public void onGuildReady(GuildReadyEvent event) { } @Override - public void onReady(@Nonnull ReadyEvent event) { + public void onReady(@NotNull ReadyEvent event) { var spawnVerify = Commands.slash("spawnverify", "Spawns a button to allow user to verify their purchases") .setDefaultPermissions(DefaultMemberPermissions.enabledFor(Permission.MANAGE_CHANNEL, Permission.MODERATE_MEMBERS)) .setGuildOnly(true); diff --git a/src/main/java/com/benaclejames/gumcord/Utils/AdminChannel.java b/src/main/java/com/benaclejames/gumcord/Utils/AdminChannel.java index cbae191..e2ec506 100644 --- a/src/main/java/com/benaclejames/gumcord/Utils/AdminChannel.java +++ b/src/main/java/com/benaclejames/gumcord/Utils/AdminChannel.java @@ -3,9 +3,9 @@ import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.entities.Guild; -import net.dv8tion.jda.api.entities.GuildChannel; import net.dv8tion.jda.api.entities.Message; -import net.dv8tion.jda.api.entities.MessageChannel; +import net.dv8tion.jda.api.entities.channel.middleman.GuildChannel; +import net.dv8tion.jda.api.entities.channel.middleman.MessageChannel; import java.awt.*; import java.time.Duration; diff --git a/src/main/resources/logback.xml b/src/main/resources/logback.xml new file mode 100644 index 0000000..8cc54a9 --- /dev/null +++ b/src/main/resources/logback.xml @@ -0,0 +1,12 @@ + + + + + %d{HH:mm:ss.SSS} %boldCyan(%-34.-34thread) %red(%10.10X{jda.shard}) %boldGreen(%-15.-15logger{0}) %highlight(%-6level) %msg%n + + + + + + + \ No newline at end of file