From 883d842a5f3388d1910c1e33217ad7559d2e0414 Mon Sep 17 00:00:00 2001 From: Presti Date: Thu, 4 May 2023 11:19:26 +0200 Subject: [PATCH 1/2] Upgrade to JDA 5 Added function to make someone join a Guild server via OAuth2 --- build.gradle | 7 +- .../jagrosh/jdautilities/command/Command.java | 16 +-- .../jdautilities/command/CommandEvent.java | 112 ++++++++-------- .../command/impl/CommandClientImpl.java | 20 +-- .../commons/utils/FinderUtil.java | 111 ++++++++-------- .../commons/waiter/EventWaiter.java | 8 +- .../examples/command/AboutCommand.java | 2 +- .../examples/command/GuildlistCommand.java | 2 +- .../examples/command/RoleinfoCommand.java | 8 +- .../examples/command/ServerinfoCommand.java | 3 +- .../jagrosh/jdautilities/menu/ButtonMenu.java | 83 +++++++----- .../com/jagrosh/jdautilities/menu/Menu.java | 7 +- .../jdautilities/menu/OrderedMenu.java | 65 +++++---- .../jagrosh/jdautilities/menu/Paginator.java | 81 ++++++++---- .../jdautilities/menu/SelectionDialog.java | 67 ++++++---- .../jagrosh/jdautilities/menu/Slideshow.java | 61 ++++++--- .../jdautilities/oauth2/OAuth2Client.java | 29 ++++- .../oauth2/entities/OAuth2Guild.java | 23 +++- .../oauth2/entities/OAuth2User.java | 27 +--- .../entities/impl/OAuth2ClientImpl.java | 42 ++++-- .../oauth2/entities/impl/OAuth2GuildImpl.java | 27 ++-- .../oauth2/entities/impl/OAuth2UserImpl.java | 123 +++++++++--------- .../oauth2/requests/OAuth2Action.java | 13 +- .../oauth2/requests/OAuth2Requester.java | 17 +-- .../oauth2/requests/OAuth2URL.java | 23 +++- .../session/DefaultSessionController.java | 6 +- .../oauth2/session/SessionData.java | 10 +- .../oauth2/state/DefaultStateController.java | 6 +- 28 files changed, 599 insertions(+), 400 deletions(-) diff --git a/build.gradle b/build.gradle index 2074d811..78b2f364 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ plugins { id 'com.github.johnrengelman.shadow' version '2.0.2' } -def versionInfo = [major: '3', minor: '1', revision: '0'] +def versionInfo = [major: '4', minor: '0', revision: '0'] task build { group = 'build' @@ -36,7 +36,7 @@ allprojects { version = versionInfo.values().join('.') ext { - jdaVersion = '4.3.0_313' + jdaVersion = '5.0.0-beta.8' slf4jVersion = '1.7.25' okhttpVersion = '3.13.0' findbugsVersion = '3.0.2' @@ -92,9 +92,6 @@ allprojects { repositories { mavenLocal() mavenCentral() - maven { - url "https://m2.dv8tion.net/releases" - } } build { diff --git a/command/src/main/java/com/jagrosh/jdautilities/command/Command.java b/command/src/main/java/com/jagrosh/jdautilities/command/Command.java index 40d2ff49..e41fb517 100644 --- a/command/src/main/java/com/jagrosh/jdautilities/command/Command.java +++ b/command/src/main/java/com/jagrosh/jdautilities/command/Command.java @@ -20,10 +20,10 @@ import java.util.function.BiConsumer; import java.util.function.Predicate; import net.dv8tion.jda.api.Permission; -import net.dv8tion.jda.api.entities.ChannelType; +import net.dv8tion.jda.api.entities.channel.ChannelType; import net.dv8tion.jda.api.entities.GuildVoiceState; -import net.dv8tion.jda.api.entities.TextChannel; -import net.dv8tion.jda.api.entities.VoiceChannel; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; +import net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel; /** *

Commands In JDA-Utilities

@@ -247,7 +247,7 @@ public final void run(CommandEvent event) if(p.name().startsWith("VOICE")) { GuildVoiceState gvc = event.getMember().getVoiceState(); - VoiceChannel vc = gvc == null ? null : gvc.getChannel(); + VoiceChannel vc = gvc == null ? null : gvc.getChannel().asVoiceChannel(); if(vc==null) { terminate(event, event.getClient().getError()+" You must be in a voice channel to use that!"); @@ -354,7 +354,7 @@ public boolean isCommandFor(String input) } /** - * Checks whether a command is allowed in a {@link net.dv8tion.jda.api.entities.TextChannel TextChannel} + * Checks whether a command is allowed in a {@link net.dv8tion.jda.api.entities.channel.concrete.TextChannel TextChannel} * by searching the channel topic for topic tags relating to the command. * *

{-{@link com.jagrosh.jdautilities.command.Command#name name}}, @@ -766,7 +766,7 @@ public enum CooldownScope USER("U:%d",""), /** - * Applies the cooldown to the {@link net.dv8tion.jda.api.entities.MessageChannel MessageChannel} the + * Applies the cooldown to the {@link net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion MessageChannel} the * command is called in. * *

The key for this is generated in the format @@ -778,7 +778,7 @@ public enum CooldownScope /** * Applies the cooldown to the calling {@link net.dv8tion.jda.api.entities.User User} local to the - * {@link net.dv8tion.jda.api.entities.MessageChannel MessageChannel} the command is called in. + * {@link net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion MessageChannel} the command is called in. * *

The key for this is generated in the format *