diff --git a/src/main/java/com/jagrosh/vortex/Vortex.java b/src/main/java/com/jagrosh/vortex/Vortex.java index 26260f4..9e087a6 100644 --- a/src/main/java/com/jagrosh/vortex/Vortex.java +++ b/src/main/java/com/jagrosh/vortex/Vortex.java @@ -47,6 +47,8 @@ import com.typesafe.config.ConfigFactory; import java.util.Arrays; import java.util.concurrent.TimeUnit; +import java.util.function.Consumer; + import net.dv8tion.jda.api.entities.Activity; import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.*; @@ -178,14 +180,16 @@ new ReloadCmd(this) //new TransferCmd(this) ) - .setHelpConsumer(event -> event.replyInDm(FormatUtil.formatHelp(event, this), m -> + .setHelpConsumer(event -> event.replyInDm(FormatUtil.formatHelp(event, this), m -> { if(event.isFromType(ChannelType.TEXT)) try { event.getMessage().addReaction(net.dv8tion.jda.api.entities.emoji.Emoji.fromFormatted(Constants.HELP_REACTION)).queue(s->{}, f->{}); } catch(PermissionException ignore) {} - }, t -> event.replyWarning("Help cannot be sent because you are blocking Direct Messages."))) + } + //, (Consumer) (t -> event.replyWarning("Help cannot be sent because you are blocking Direct Messages.")) + )) .build(); shards = new MultiBotManager.MultiBotManagerBuilder() .addBot(config.getString("pro-token"), Constants.INTENTS) diff --git a/src/main/java/com/jagrosh/vortex/commands/moderation/SlowmodeCmd.java b/src/main/java/com/jagrosh/vortex/commands/moderation/SlowmodeCmd.java index 5186549..1ed1b69 100644 --- a/src/main/java/com/jagrosh/vortex/commands/moderation/SlowmodeCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/moderation/SlowmodeCmd.java @@ -49,8 +49,8 @@ if(event.getArgs().isEmpty()) { - int slowmodeDuration = vortex.getDatabase().tempslowmodes.timeUntilDisableSlowmode(event.getChannel().asTextChannel()); - int slowmodeTime = event.getChannel().asTextChannel().getSlowmode(); + int slowmodeDuration = vortex.getDatabase().tempslowmodes.timeUntilDisableSlowmode(event.getTextChannel()); + int slowmodeTime = event.getTextChannel().getSlowmode(); if(slowmodeTime <= 0) { @@ -70,8 +70,8 @@ if(args.equals("0") || args.equalsIgnoreCase("off")) { - vortex.getDatabase().tempslowmodes.clearSlowmode(event.getChannel().asTextChannel()); - event.getChannel().asTextChannel().getManager() + vortex.getDatabase().tempslowmodes.clearSlowmode(event.getTextChannel()); + event.getTextChannel().getManager() .setSlowmode(0) .reason(LogUtil.auditReasonFormat(event.getMember(), "Disabled slowmode")) .queue(); @@ -110,14 +110,14 @@ return; } - event.getChannel().asTextChannel().getManager() + event.getTextChannel().getManager() .setSlowmode(slowmodeTime) .reason(LogUtil.auditReasonFormat(event.getMember(), slowmodeDuration/60, "Enabled slowmode")) .queue(s -> { if(slowmodeDuration <= 0) return; vortex.getThreadpool().schedule( - () -> vortex.getDatabase().tempslowmodes.setSlowmode(event.getChannel().asTextChannel(), Instant.now().plus(slowmodeDuration, ChronoUnit.SECONDS)), + () -> vortex.getDatabase().tempslowmodes.setSlowmode(event.getTextChannel(), Instant.now().plus(slowmodeDuration, ChronoUnit.SECONDS)), 10, TimeUnit.SECONDS ); }); diff --git a/src/main/java/com/jagrosh/vortex/commands/moderation/SoftbanCmd.java b/src/main/java/com/jagrosh/vortex/commands/moderation/SoftbanCmd.java index b02b3a8..c8554f0 100644 --- a/src/main/java/com/jagrosh/vortex/commands/moderation/SoftbanCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/moderation/SoftbanCmd.java @@ -89,10 +89,10 @@ { Member m = toSoftban.get(i); boolean last = i+1 == toSoftban.size(); - event.getGuild().ban(m, 1, TimeUnit.DAYS).setReason(reason).queue(success -> + event.getGuild().ban(m, 1, TimeUnit.DAYS).reason(reason).queue(success -> { builder.append("\n").append(event.getClient().getSuccess()).append(" Successfully softbanned ").append(FormatUtil.formatUser(m.getUser())); - event.getGuild().unban(m.getUser().getId()).reason(unbanreason).queueAfter(4, TimeUnit.SECONDS); + event.getGuild().unban(m.getUser()).reason(unbanreason).queueAfter(4, TimeUnit.SECONDS); if(last) event.reply(builder.toString()); }, failure -> diff --git a/src/main/java/com/jagrosh/vortex/commands/moderation/UnbanCmd.java b/src/main/java/com/jagrosh/vortex/commands/moderation/UnbanCmd.java index 6d8b88d..e833529 100644 --- a/src/main/java/com/jagrosh/vortex/commands/moderation/UnbanCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/moderation/UnbanCmd.java @@ -23,6 +23,8 @@ import com.jagrosh.vortex.utils.ArgsUtil.ResolvedArgs; import com.jagrosh.vortex.utils.FormatUtil; import com.jagrosh.vortex.utils.LogUtil; +import net.dv8tion.jda.api.entities.UserSnowflake; + import java.util.LinkedList; import java.util.List; //import net.dv8tion.jda.api.entities.Guild.Ban; @@ -89,7 +91,7 @@ { Long ban = toUnban.get(i); boolean last = i+1 == toUnban.size(); - event.getGuild().unban(Long.toString(ban)).reason(reason).queue(success -> + event.getGuild().unban(UserSnowflake.fromId(ban)).reason(reason).queue(success -> { builder.append("\n").append(event.getClient().getSuccess()).append(" Successfully unbanned <@").append(ban).append(">"); if(last) diff --git a/src/main/java/com/jagrosh/vortex/commands/owner/EvalCmd.java b/src/main/java/com/jagrosh/vortex/commands/owner/EvalCmd.java index 9e35080..4965d82 100644 --- a/src/main/java/com/jagrosh/vortex/commands/owner/EvalCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/owner/EvalCmd.java @@ -42,7 +42,7 @@ @Override protected void execute(CommandEvent event) { - event.getChannel().asTextChannel().sendTyping().queue(); + event.getTextChannel().sendTyping().queue(); event.async(() -> { ScriptEngine se = new ScriptEngineManager().getEngineByName("Nashorn"); @@ -50,7 +50,7 @@ se.put("event", event); se.put("jda", event.getJDA()); se.put("guild", event.getGuild()); - se.put("channel", event.getChannel().asTextChannel()); + se.put("channel", event.getTextChannel()); String args = event.getArgs().replaceAll("([^(]+?)\\s*->", "function($1)"); try { diff --git a/src/main/java/com/jagrosh/vortex/commands/settings/PunishmentCmd.java b/src/main/java/com/jagrosh/vortex/commands/settings/PunishmentCmd.java index a738313..8bd53d5 100644 --- a/src/main/java/com/jagrosh/vortex/commands/settings/PunishmentCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/settings/PunishmentCmd.java @@ -166,7 +166,8 @@ } event.reply(new MessageCreateBuilder() .addContent(event.getClient().getSuccess()) - .append(" ").append(FormatUtil.filterEveryone(successMessage)) + .addContent(" ") + .addContent(FormatUtil.filterEveryone(successMessage)) .setEmbeds(new EmbedBuilder().setColor(event.getSelfMember().getColor()) .addField(vortex.getDatabase().actions.getAllPunishmentsDisplay(event.getGuild())) .build()) diff --git a/src/main/java/com/jagrosh/vortex/commands/settings/SettingsCmd.java b/src/main/java/com/jagrosh/vortex/commands/settings/SettingsCmd.java index 995cd7a..cf9ba13 100644 --- a/src/main/java/com/jagrosh/vortex/commands/settings/SettingsCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/settings/SettingsCmd.java @@ -46,7 +46,7 @@ protected void execute(CommandEvent event) { PremiumInfo pi = vortex.getDatabase().premium.getPremiumInfo(event.getGuild()); - event.getChannel().asTextChannel().sendMessage(new MessageCreateBuilder() + event.getTextChannel().sendMessage(new MessageCreateBuilder() .addContent(FormatUtil.filterEveryone("**" + event.getSelfUser().getName() + "** settings on **" + event.getGuild().getName() + "**:")) .setEmbeds(new EmbedBuilder() //.setThumbnail(event.getGuild().getIconId()==null ? event.getSelfUser().getEffectiveAvatarUrl() : event.getGuild().getIconUrl()) diff --git a/src/main/java/com/jagrosh/vortex/commands/settings/SetupCmd.java b/src/main/java/com/jagrosh/vortex/commands/settings/SetupCmd.java index 7b06f6c..d334625 100644 --- a/src/main/java/com/jagrosh/vortex/commands/settings/SetupCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/settings/SetupCmd.java @@ -64,7 +64,7 @@ { waitForConfirmation(event, "This will enable all automod defaults. Any existing settings will not be overwritten.", () -> { - event.getChannel().asTextChannel().sendTyping().queue(); + event.getTextChannel().sendTyping().queue(); StringBuilder sb = new StringBuilder("**Automod setup complete!**"); AutomodSettings ams = vortex.getDatabase().automod.getSettings(event.getGuild()); if(ams.inviteStrikes==0) @@ -179,11 +179,11 @@ sb.append(event.getClient().getSuccess()).append(" Role initialized!\n"); m.editMessage(sb + Constants.LOADING+" Making Category overrides...").complete(); PermissionOverride po; - for(net.dv8tion.jda.api.entities.Category cat: event.getGuild().getCategories()) + for(net.dv8tion.jda.api.entities.channel.concrete.Category cat: event.getGuild().getCategories()) { po = cat.getPermissionOverride(mutedRole); if(po==null) - cat.createPermissionOverride(mutedRole).setDeny(Permission.MESSAGE_SEND, Permission.MESSAGE_ADD_REACTION, Permission.VOICE_CONNECT, Permission.VOICE_SPEAK, Permission.CREATE_PUBLIC_THREADS, Permission.CREATE_PRIVATE_THREADS).complete(); + cat.upsertPermissionOverride(mutedRole).deny(Permission.MESSAGE_SEND, Permission.MESSAGE_ADD_REACTION, Permission.VOICE_CONNECT, Permission.VOICE_SPEAK, Permission.CREATE_PUBLIC_THREADS, Permission.CREATE_PRIVATE_THREADS).complete(); else po.getManager().deny(Permission.MESSAGE_SEND, Permission.MESSAGE_ADD_REACTION, Permission.VOICE_CONNECT, Permission.VOICE_SPEAK, Permission.CREATE_PUBLIC_THREADS, Permission.CREATE_PRIVATE_THREADS).complete(); } @@ -193,7 +193,7 @@ { po = tc.getPermissionOverride(mutedRole); if(po==null) - tc.createPermissionOverride(mutedRole).setDeny(Permission.MESSAGE_SEND, Permission.MESSAGE_ADD_REACTION, Permission.CREATE_PUBLIC_THREADS, Permission.CREATE_PRIVATE_THREADS).complete(); + tc.upsertPermissionOverride(mutedRole).deny(Permission.MESSAGE_SEND, Permission.MESSAGE_ADD_REACTION, Permission.CREATE_PUBLIC_THREADS, Permission.CREATE_PRIVATE_THREADS).complete(); else po.getManager().deny(Permission.MESSAGE_SEND, Permission.MESSAGE_ADD_REACTION, Permission.CREATE_PUBLIC_THREADS, Permission.CREATE_PRIVATE_THREADS).complete(); } @@ -203,7 +203,7 @@ { po = vc.getPermissionOverride(mutedRole); if(po==null) - vc.createPermissionOverride(mutedRole).setDeny(Permission.VOICE_CONNECT, Permission.VOICE_SPEAK).complete(); + vc.upsertPermissionOverride(mutedRole).deny(Permission.VOICE_CONNECT, Permission.VOICE_SPEAK).complete(); else po.getManager().deny(Permission.VOICE_CONNECT, Permission.VOICE_SPEAK).complete(); } @@ -229,7 +229,7 @@ { if(re.getName().equals(CONFIRM)) confirm.run(); - }).build().display(event.getChannel().asTextChannel()); + }).build().display(event.getTextChannel()); } private class VerificationSetupCmd extends Command diff --git a/src/main/java/com/jagrosh/vortex/commands/tools/ExportCmd.java b/src/main/java/com/jagrosh/vortex/commands/tools/ExportCmd.java index bed5682..7723d7c 100644 --- a/src/main/java/com/jagrosh/vortex/commands/tools/ExportCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/tools/ExportCmd.java @@ -22,8 +22,11 @@ import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.entities.Guild; import com.jagrosh.jdautilities.command.CooldownScope; +import net.dv8tion.jda.api.utils.FileUpload; import org.json.JSONObject; +import java.io.ByteArrayInputStream; + /** * * @author John Grosh (john.a.grosh@gmail.com) @@ -62,6 +65,7 @@ .put("inviteWhitelist", db.inviteWhitelist.getWhitelistJson(g)) .put("filters", db.filters.getFiltersJson(g)) .put("premium", db.premium.getPremiumInfoJson(g)); - event.getChannel().asTextChannel().sendFile(obj.toString(1).getBytes(), "vortex_data_" + g.getId() + ".json").queue(); + event.getTextChannel().sendFiles( + FileUpload.fromData(obj.toString(1).getBytes(), "vortex_data_" + g.getId() + ".json")).queue(); } } diff --git a/src/main/java/com/jagrosh/vortex/commands/tools/InvitepruneCmd.java b/src/main/java/com/jagrosh/vortex/commands/tools/InvitepruneCmd.java index 5fbb7e3..4b4ac60 100644 --- a/src/main/java/com/jagrosh/vortex/commands/tools/InvitepruneCmd.java +++ b/src/main/java/com/jagrosh/vortex/commands/tools/InvitepruneCmd.java @@ -83,7 +83,7 @@ private void pruneInvites(int uses, CommandEvent event) { - event.getChannel().asTextChannel().sendTyping().queue(); + event.getTextChannel().sendTyping().queue(); event.getGuild().retrieveInvites().queue(list -> { List toPrune = list.stream().filter(i -> i.getInviter()!=null && !i.getInviter().isBot() && i.getUses()<=uses).collect(Collectors.toList()); @@ -105,6 +105,6 @@ { if(re.getName().equals(CONFIRM)) confirm.run(); - }).build().display(event.getChannel().asTextChannel()); + }).build().display(event.getTextChannel()); } } diff --git a/src/main/java/com/jagrosh/vortex/utils/OtherUtil.java b/src/main/java/com/jagrosh/vortex/utils/OtherUtil.java index 41e1f42..5c9539d 100644 --- a/src/main/java/com/jagrosh/vortex/utils/OtherUtil.java +++ b/src/main/java/com/jagrosh/vortex/utils/OtherUtil.java @@ -150,7 +150,7 @@ case TEAM_USER: return "\u2753"; case UNKNOWN: return "\u2753"; case VERIFIED_BOT: return Emoji.BOT_VERIFIED; - case SYSTEM: return Emoji.BOT_SYSTEM; + //case SYSTEM: return Emoji.BOT_SYSTEM; default: return "\u2753"; } }