Skip to content
This repository was archived by the owner on Feb 4, 2025. It is now read-only.

Upgrade to JDA 5 #142

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -36,11 +36,11 @@ allprojects {
version = versionInfo.values().join('.')

ext {
jdaVersion = '4.3.0_313'
slf4jVersion = '1.7.25'
jdaVersion = '5.0.0-beta.8'
slf4jVersion = '2.0.7'
okhttpVersion = '3.13.0'
findbugsVersion = '3.0.2'
jsonVersion = '20160810'
jsonVersion = '20230227'
junitVersion = '4.13.1' // TODO Move to junit 5?

dependencies {
Expand Down Expand Up @@ -92,9 +92,6 @@ allprojects {
repositories {
mavenLocal()
mavenCentral()
maven {
url "https://m2.dv8tion.net/releases"
}
}

build {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
* <h1><b>Commands In JDA-Utilities</b></h1>
Expand Down Expand Up @@ -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!");
Expand Down Expand Up @@ -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.
*
* <p>{-{@link com.jagrosh.jdautilities.command.Command#name name}},
Expand Down Expand Up @@ -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.
*
* <p>The key for this is generated in the format
Expand All @@ -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.
*
* <p>The key for this is generated in the format
* <ul>
Expand Down Expand Up @@ -851,7 +851,7 @@ public enum CooldownScope
* Applies this cooldown globally.
*
* <p>As this implies: the command will be unusable on the instance of JDA in all types of
* {@link net.dv8tion.jda.api.entities.MessageChannel MessageChannel}s until the cooldown has ended.
* {@link net.dv8tion.jda.api.entities.channel.unions.MessageChannelUnion MessageChannel}s until the cooldown has ended.
*
* <p>The key for this is {@code <command-name>|globally}
*/
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@
import net.dv8tion.jda.api.OnlineStatus;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.entities.channel.ChannelType;
import net.dv8tion.jda.api.events.GenericEvent;
import net.dv8tion.jda.api.events.ReadyEvent;
import net.dv8tion.jda.api.events.ShutdownEvent;
import net.dv8tion.jda.api.events.session.ReadyEvent;
import net.dv8tion.jda.api.events.session.ShutdownEvent;
import net.dv8tion.jda.api.events.guild.GuildJoinEvent;
import net.dv8tion.jda.api.events.guild.GuildLeaveEvent;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.events.message.guild.GuildMessageDeleteEvent;
import net.dv8tion.jda.api.events.message.MessageDeleteEvent;
import net.dv8tion.jda.api.hooks.EventListener;
import net.dv8tion.jda.internal.utils.Checks;
import okhttp3.*;
Expand Down Expand Up @@ -444,8 +445,8 @@ public void onEvent(GenericEvent event)
if(event instanceof MessageReceivedEvent)
onMessageReceived((MessageReceivedEvent)event);

else if(event instanceof GuildMessageDeleteEvent && usesLinkedDeletion())
onMessageDelete((GuildMessageDeleteEvent) event);
else if(event instanceof MessageDeleteEvent && usesLinkedDeletion())
onMessageDelete((MessageDeleteEvent) event);

else if(event instanceof GuildJoinEvent)
{
Expand Down Expand Up @@ -536,7 +537,7 @@ private void onMessageReceived(MessageReceivedEvent event)
listener.onCompletedCommand(cevent, null);
return; // Help Consumer is done
}
else if(event.isFromType(ChannelType.PRIVATE) || event.getTextChannel().canTalk())
else if(event.isFromType(ChannelType.PRIVATE) || event.getChannel().canTalk())
{
String name = parts[0];
String args = parts[1]==null ? "" : parts[1];
Expand Down Expand Up @@ -655,8 +656,9 @@ else if (jda.getShardManager() != null)
}
}

private void onMessageDelete(GuildMessageDeleteEvent event)
private void onMessageDelete(MessageDeleteEvent event)
{
if (!event.isFromGuild()) return;
// We don't need to cover whether or not this client usesLinkedDeletion() because
// that is checked in onEvent(Event) before this is even called.
synchronized(linkMap)
Expand All @@ -665,8 +667,8 @@ private void onMessageDelete(GuildMessageDeleteEvent event)
{
Set<Message> messages = linkMap.get(event.getMessageIdLong());
if(messages.size()>1 && event.getGuild().getSelfMember()
.hasPermission(event.getChannel(), Permission.MESSAGE_MANAGE))
event.getChannel().deleteMessages(messages).queue(unused -> {}, ignored -> {});
.hasPermission(event.getChannel().asGuildMessageChannel(), Permission.MESSAGE_MANAGE))
event.getChannel().asGuildMessageChannel().deleteMessages(messages).queue(unused -> {}, ignored -> {});
else if(messages.size()>0)
messages.forEach(m -> m.delete().queue(unused -> {}, ignored -> {}));
}
Expand Down
Loading