Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to JDA 5 & bump to JDA-Chewtils 2.0 #35

Merged
merged 5 commits into from
Jan 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 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 "7.0.0"
}

def versionInfo = [major: '1', minor: System.getenv("BUILD_NUMBER").toString()]
def versionInfo = [major: '2', minor: System.getenv("BUILD_NUMBER") ?: "0"]
rtm516 marked this conversation as resolved.
Show resolved Hide resolved

task build {
group = 'build'
Expand All @@ -36,7 +36,7 @@ allprojects {
version = versionInfo.values().join('.')

ext {
jdaVersion = '4.3.0_313'
jdaVersion = '5.0.0-alpha.1'
slf4jVersion = '1.7.25'
okhttpVersion = '3.13.0'
findbugsVersion = '3.0.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
import java.util.function.BiConsumer;
import java.util.function.Predicate;
import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.AudioChannel;
import net.dv8tion.jda.api.entities.ChannelType;
import net.dv8tion.jda.api.entities.GuildVoiceState;
import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.entities.VoiceChannel;

/**
* <h1><b>Commands In JDA-Utilities</b></h1>
Expand Down Expand Up @@ -295,7 +295,7 @@ public final void run(CommandEvent event)
if(p.name().startsWith("VOICE"))
{
GuildVoiceState gvc = event.getMember().getVoiceState();
VoiceChannel vc = gvc == null ? null : gvc.getChannel();
AudioChannel vc = gvc == null ? null : gvc.getChannel();
if(vc==null)
{
terminate(event, event.getClient().getError()+" You must be in a voice channel to use that!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public void reply(String message, Consumer<Message> success, Consumer<Throwable>
*/
public void reply(MessageEmbed embed)
{
event.getChannel().sendMessage(embed).queue(m -> {
event.getChannel().sendMessageEmbeds(embed).queue(m -> {
if(event.isFromType(ChannelType.TEXT))
linkId(m);
});
Expand All @@ -244,7 +244,7 @@ public void reply(MessageEmbed embed)
*/
public void reply(MessageEmbed embed, Consumer<Message> success)
{
event.getChannel().sendMessage(embed).queue(m -> {
event.getChannel().sendMessageEmbeds(embed).queue(m -> {
if(event.isFromType(ChannelType.TEXT))
linkId(m);
success.accept(m);
Expand All @@ -269,7 +269,7 @@ public void reply(MessageEmbed embed, Consumer<Message> success)
*/
public void reply(MessageEmbed embed, Consumer<Message> success, Consumer<Throwable> failure)
{
event.getChannel().sendMessage(embed).queue(m -> {
event.getChannel().sendMessageEmbeds(embed).queue(m -> {
if(event.isFromType(ChannelType.TEXT))
linkId(m);
success.accept(m);
Expand Down Expand Up @@ -425,7 +425,7 @@ public void replyFormatted(String format, Object... args)
public void replyOrAlternate(MessageEmbed embed, String alternateMessage)
{
try {
event.getChannel().sendMessage(embed).queue();
event.getChannel().sendMessageEmbeds(embed).queue();
} catch(PermissionException e) {
reply(alternateMessage);
}
Expand Down Expand Up @@ -577,7 +577,7 @@ public void replyInDm(MessageEmbed embed)
reply(embed);
else
{
event.getAuthor().openPrivateChannel().queue(pc -> pc.sendMessage(embed).queue());
event.getAuthor().openPrivateChannel().queue(pc -> pc.sendMessageEmbeds(embed).queue());
}
}

Expand All @@ -601,10 +601,10 @@ public void replyInDm(MessageEmbed embed)
public void replyInDm(MessageEmbed embed, Consumer<Message> success)
{
if(event.isFromType(ChannelType.PRIVATE))
getPrivateChannel().sendMessage(embed).queue(success);
getPrivateChannel().sendMessageEmbeds(embed).queue(success);
else
{
event.getAuthor().openPrivateChannel().queue(pc -> pc.sendMessage(embed).queue(success));
event.getAuthor().openPrivateChannel().queue(pc -> pc.sendMessageEmbeds(embed).queue(success));
}
}

Expand All @@ -630,10 +630,10 @@ public void replyInDm(MessageEmbed embed, Consumer<Message> success)
public void replyInDm(MessageEmbed embed, Consumer<Message> success, Consumer<Throwable> failure)
{
if(event.isFromType(ChannelType.PRIVATE))
getPrivateChannel().sendMessage(embed).queue(success, failure);
getPrivateChannel().sendMessageEmbeds(embed).queue(success, failure);
else
{
event.getAuthor().openPrivateChannel().queue(pc -> pc.sendMessage(embed).queue(success, failure), failure);
event.getAuthor().openPrivateChannel().queue(pc -> pc.sendMessageEmbeds(embed).queue(success, failure), failure);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.jagrosh.jdautilities.command;

import net.dv8tion.jda.api.Permission;
import net.dv8tion.jda.api.entities.AudioChannel;
import net.dv8tion.jda.api.entities.ChannelType;
import net.dv8tion.jda.api.entities.GuildVoiceState;
import net.dv8tion.jda.api.entities.Member;
Expand Down Expand Up @@ -288,7 +289,7 @@ public final void run(SlashCommandEvent event, CommandClient client)
if(p.name().startsWith("VOICE"))
{
GuildVoiceState gvc = event.getMember().getVoiceState();
VoiceChannel vc = gvc == null ? null : gvc.getChannel();
AudioChannel vc = gvc == null ? null : gvc.getChannel();
if(vc==null)
{
terminate(event, client.getError()+" You must be in a voice channel to use that!", client);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
import net.dv8tion.jda.api.events.guild.GuildJoinEvent;
import net.dv8tion.jda.api.events.guild.GuildLeaveEvent;
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
import net.dv8tion.jda.api.events.message.MessageDeleteEvent;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.events.message.guild.GuildMessageDeleteEvent;
import net.dv8tion.jda.api.hooks.EventListener;
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
import net.dv8tion.jda.api.interactions.commands.privileges.CommandPrivilege;
Expand Down Expand Up @@ -537,8 +537,8 @@ public void onEvent(GenericEvent event)
else if(event instanceof SlashCommandEvent)
onSlashCommand((SlashCommandEvent)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 @@ -883,8 +883,11 @@ else if (jda.getShardManager() != null)
}
}

private void onMessageDelete(GuildMessageDeleteEvent event)
private void onMessageDelete(MessageDeleteEvent event)
{
// Check we are in a guild since there is no guild specific event now
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 @@ -893,8 +896,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.getTextChannel(), Permission.MESSAGE_MANAGE))
event.getTextChannel().deleteMessages(messages).queue(unused -> {}, ignored -> {});
else if(messages.size()>0)
messages.forEach(m -> m.delete().queue(unused -> {}, ignored -> {}));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ else if(found.size()>1)

event.reply(new MessageBuilder()
.append(title)
.setEmbed(new EmbedBuilder()
.setEmbeds(new EmbedBuilder()
.setDescription(desr.toString().trim())
.setColor(role.getColor()).build())
.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected void execute(CommandEvent event)
}
String str = LINESTART + "ID: **" + guild.getId() + "**\n"
+ LINESTART + "Owner: " + (owner == null ? "Unknown" : "**" + owner.getUser().getName() + "**#" + owner.getUser().getDiscriminator()) + "\n"
+ LINESTART + "Location: " + (guild.getRegion().getEmoji().isEmpty() ? NO_REGION : guild.getRegion().getEmoji()) + " **" + guild.getRegion().getName() + "**\n"
+ LINESTART + "Location: " + (guild.getVoiceChannels().get(0).getRegion().getEmoji().isEmpty() ? NO_REGION : guild.getVoiceChannels().get(0).getRegion().getEmoji()) + " **" + guild.getVoiceChannels().get(0).getRegion().getName() + "**\n"
rtm516 marked this conversation as resolved.
Show resolved Hide resolved
+ LINESTART + "Creation: **" + guild.getTimeCreated().format(DateTimeFormatter.RFC_1123_DATE_TIME) + "**\n"
+ LINESTART + "Users: **" + guild.getMemberCache().size() + "** (" + onlineCount + " online, " + botCount + " bots)\n"
+ LINESTART + "Channels: **" + guild.getTextChannelCache().size() + "** Text, **" + guild.getVoiceChannelCache().size() + "** Voice, **" + guild.getCategoryCache().size() + "** Categories\n"
Expand All @@ -87,6 +87,6 @@ protected void execute(CommandEvent event)
builder.setThumbnail(guild.getIconUrl());
builder.setColor(owner == null ? null : owner.getColor());
builder.setDescription(str);
event.reply(new MessageBuilder().append(title).setEmbed(builder.build()).build());
event.reply(new MessageBuilder().append(title).setEmbeds(builder.build()).build());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ private Message getMessage()
if(text!=null)
mbuilder.append(text);
if(description!=null)
mbuilder.setEmbed(new EmbedBuilder().setColor(color).setDescription(description).build());
mbuilder.setEmbeds(new EmbedBuilder().setColor(color).setDescription(description).build());
return mbuilder.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ private Message renderPage(int pageNum)
{
MessageBuilder mbuilder = new MessageBuilder();
MessageEmbed membed = this.embeds.get(pageNum-1);
mbuilder.setEmbed(membed);
mbuilder.setEmbeds(membed);
if(text != null)
mbuilder.append(text.apply(pageNum, embeds.size()));
return mbuilder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ private Message getMessage()
StringBuilder sb = new StringBuilder();
for(int i=0; i<choices.size(); i++)
sb.append("\n").append(getEmoji(i)).append(" ").append(choices.get(i));
mbuilder.setEmbed(new EmbedBuilder().setColor(color)
mbuilder.setEmbeds(new EmbedBuilder().setColor(color)
.setDescription(description==null ? sb.toString() : description+sb.toString()).build());
return mbuilder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ private Message renderPage(int pageNum)
ebuilder.setColor(color.apply(pageNum, pages));
if(showPageNumbers)
ebuilder.setFooter("Page "+pageNum+"/"+pages, null);
mbuilder.setEmbed(ebuilder.build());
mbuilder.setEmbeds(ebuilder.build());
if(text!=null)
mbuilder.append(text.apply(pageNum, pages));
return mbuilder.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ private Message render(int selection)
String content = text.apply(selection);
if(content!=null)
mbuilder.append(content);
return mbuilder.setEmbed(new EmbedBuilder()
return mbuilder.setEmbeds(new EmbedBuilder()
.setColor(color.apply(selection))
.setDescription(sbuilder.toString())
.build()).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ private Message renderPage(int pageNum)
ebuilder.setDescription(description.apply(pageNum, urls.size()));
if(showPageNumbers)
ebuilder.setFooter("Image "+pageNum+"/"+urls.size(), null);
mbuilder.setEmbed(ebuilder.build());
mbuilder.setEmbeds(ebuilder.build());
if(text!=null)
mbuilder.append(text.apply(pageNum, urls.size()));
return mbuilder.build();
Expand Down
57 changes: 0 additions & 57 deletions pom.xml

This file was deleted.