From 136e9ed0bcf7385163c127b6a571039eea94dc2b Mon Sep 17 00:00:00 2001 From: elijahtaylorr <45134707+elijahtaylorr@users.noreply.github.com> Date: Thu, 5 Mar 2026 00:54:11 +0800 Subject: [PATCH] Initial commit --- pom.xml | 62 ++++++-- src/main/java/com/jagrosh/jmusicbot/Bot.java | 4 + .../java/com/jagrosh/jmusicbot/JMusicBot.java | 139 ++++++++---------- .../java/com/jagrosh/jmusicbot/Listener.java | 11 +- .../jagrosh/jmusicbot/audio/AudioHandler.java | 16 +- .../jmusicbot/audio/NowplayingHandler.java | 14 +- .../jmusicbot/commands/MusicCommand.java | 11 +- .../jmusicbot/commands/admin/SettcCmd.java | 2 +- .../jmusicbot/commands/admin/SetvcCmd.java | 2 +- .../commands/general/SettingsCmd.java | 16 +- .../commands/music/NowplayingCmd.java | 4 +- .../jmusicbot/commands/music/QueueCmd.java | 10 +- .../jmusicbot/commands/owner/DebugCmd.java | 7 +- .../jmusicbot/commands/owner/EvalCmd.java | 2 +- .../jagrosh/jmusicbot/settings/Settings.java | 4 +- .../jagrosh/jmusicbot/utils/FormatUtil.java | 4 +- 16 files changed, 171 insertions(+), 137 deletions(-) diff --git a/pom.xml b/pom.xml index b8b3506..2b8eb4b 100644 --- a/pom.xml +++ b/pom.xml @@ -8,9 +8,9 @@ - dv8tion - m2-dv8tion - https://m2.dv8tion.net/releases + chew + m2-chew + https://m2.chew.pro/releases central @@ -42,25 +42,63 @@ net.dv8tion JDA - 4.4.1_353 + 6.3.1 + + + club.minnced + jdave-api + 0.1.7 + + + club.minnced + jdave-native-linux-x86-64 + 0.1.7 - com.jagrosh - jda-utilities - 3.0.5 + club.minnced + jdave-native-linux-aarch64 + 0.1.7 + + + club.minnced + jdave-native-win-x86-64 + 0.1.7 + + + club.minnced + jdave-native-darwin + 0.1.7 + + + pw.chew + jda-chewtils + 2.2.1 + compile pom + + pw.chew + jda-chewtils-command + 2.2.1 + compile + + + pw.chew + jda-chewtils-examples + 2.2.1 + compile + dev.arbjerg lavaplayer - 2.2.1 + 2.2.4 dev.lavalink.youtube common - 1.5.2 + 1.13.3 com.github.jagrosh @@ -77,7 +115,7 @@ ch.qos.logback logback-classic - 1.2.13 + 1.5.18 com.typesafe @@ -149,7 +187,7 @@ UTF-8 - 11 - 11 + 25 + 25 diff --git a/src/main/java/com/jagrosh/jmusicbot/Bot.java b/src/main/java/com/jagrosh/jmusicbot/Bot.java index de6d6f7..915e4f5 100644 --- a/src/main/java/com/jagrosh/jmusicbot/Bot.java +++ b/src/main/java/com/jagrosh/jmusicbot/Bot.java @@ -27,6 +27,7 @@ import com.jagrosh.jmusicbot.playlist.PlaylistLoader; import com.jagrosh.jmusicbot.settings.SettingsManager; import java.util.Objects; import net.dv8tion.jda.api.JDA; +import net.dv8tion.jda.api.OnlineStatus; import net.dv8tion.jda.api.entities.Activity; import net.dv8tion.jda.api.entities.Guild; @@ -121,6 +122,9 @@ public class Bot Activity game = config.getGame()==null || config.getGame().getName().equalsIgnoreCase("none") ? null : config.getGame(); if(!Objects.equals(jda.getPresence().getActivity(), game)) jda.getPresence().setActivity(game); + OnlineStatus status = config.getStatus(); + if(status != OnlineStatus.UNKNOWN && jda.getPresence().getStatus() != status) + jda.getPresence().setStatus(status); } public void shutdown() diff --git a/src/main/java/com/jagrosh/jmusicbot/JMusicBot.java b/src/main/java/com/jagrosh/jmusicbot/JMusicBot.java index 30409a6..0e1ac87 100644 --- a/src/main/java/com/jagrosh/jmusicbot/JMusicBot.java +++ b/src/main/java/com/jagrosh/jmusicbot/JMusicBot.java @@ -30,8 +30,8 @@ import com.jagrosh.jmusicbot.settings.SettingsManager; import com.jagrosh.jmusicbot.utils.OtherUtil; import java.awt.Color; import java.util.Arrays; -import javax.security.auth.login.LoginException; import net.dv8tion.jda.api.*; +import net.dv8tion.jda.api.audio.AudioModuleConfig; import net.dv8tion.jda.api.entities.Activity; import net.dv8tion.jda.api.requests.GatewayIntent; import net.dv8tion.jda.api.utils.cache.CacheFlag; @@ -39,27 +39,28 @@ import net.dv8tion.jda.api.exceptions.ErrorResponseException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import ch.qos.logback.classic.Level; +import club.minnced.discord.jdave.interop.JDaveSessionFactory; /** * * @author John Grosh (jagrosh) */ -public class JMusicBot -{ +public class JMusicBot { public final static Logger LOG = LoggerFactory.getLogger(JMusicBot.class); - public final static Permission[] RECOMMENDED_PERMS = {Permission.MESSAGE_READ, Permission.MESSAGE_WRITE, Permission.MESSAGE_HISTORY, Permission.MESSAGE_ADD_REACTION, - Permission.MESSAGE_EMBED_LINKS, Permission.MESSAGE_ATTACH_FILES, Permission.MESSAGE_MANAGE, Permission.MESSAGE_EXT_EMOJI, - Permission.VOICE_CONNECT, Permission.VOICE_SPEAK, Permission.NICKNAME_CHANGE}; - public final static GatewayIntent[] INTENTS = {GatewayIntent.DIRECT_MESSAGES, GatewayIntent.GUILD_MESSAGES, GatewayIntent.GUILD_MESSAGE_REACTIONS, GatewayIntent.GUILD_VOICE_STATES}; - + public final static Permission[] RECOMMENDED_PERMS = { Permission.VIEW_CHANNEL, Permission.MESSAGE_SEND, + Permission.MESSAGE_HISTORY, Permission.MESSAGE_ADD_REACTION, + Permission.MESSAGE_EMBED_LINKS, Permission.MESSAGE_ATTACH_FILES, Permission.MESSAGE_MANAGE, + Permission.MESSAGE_EXT_EMOJI, + Permission.VOICE_CONNECT, Permission.VOICE_SPEAK, Permission.NICKNAME_CHANGE }; + public final static GatewayIntent[] INTENTS = { GatewayIntent.MESSAGE_CONTENT, GatewayIntent.DIRECT_MESSAGES, + GatewayIntent.GUILD_MESSAGES, GatewayIntent.GUILD_MESSAGE_REACTIONS, GatewayIntent.GUILD_VOICE_STATES }; + /** * @param args the command line arguments */ - public static void main(String[] args) - { - if(args.length > 0) - switch(args[0].toLowerCase()) - { + public static void main(String[] args) { + if (args.length > 0) + switch (args[0].toLowerCase()) { case "generate-config": BotConfig.writeDefaultConfig(); return; @@ -67,117 +68,106 @@ public class JMusicBot } startBot(); } - - private static void startBot() - { + + private static void startBot() { // create prompt to handle startup Prompt prompt = new Prompt("JMusicBot"); - + // startup checks OtherUtil.checkVersion(prompt); OtherUtil.checkJavaVersion(prompt); - + // load config BotConfig config = new BotConfig(prompt); config.load(); - if(!config.isValid()) + if (!config.isValid()) return; LOG.info("Loaded config from " + config.getConfigLocation()); // set log level from config ((ch.qos.logback.classic.Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME)).setLevel( Level.toLevel(config.getLogLevel(), Level.INFO)); - + // set up the listener EventWaiter waiter = new EventWaiter(); SettingsManager settings = new SettingsManager(); Bot bot = new Bot(waiter, config, settings); CommandClient client = createCommandClient(config, settings, bot); - - - if(!prompt.isNoGUI()) - { - try - { + + if (!prompt.isNoGUI()) { + try { GUI gui = new GUI(bot); bot.setGUI(gui); gui.init(); LOG.info("Loaded config from " + config.getConfigLocation()); - } - catch(Exception e) - { + } catch (Exception e) { LOG.error("Could not start GUI. If you are " + "running on a server or in a location where you cannot display a " + "window, please run in nogui mode using the -Dnogui=true flag."); } } - + // attempt to log in and start - try - { + try { JDA jda = JDABuilder.create(config.getToken(), Arrays.asList(INTENTS)) .enableCache(CacheFlag.MEMBER_OVERRIDES, CacheFlag.VOICE_STATE) - .disableCache(CacheFlag.ACTIVITY, CacheFlag.CLIENT_STATUS, CacheFlag.EMOTE, CacheFlag.ONLINE_STATUS) + .disableCache(CacheFlag.ACTIVITY, CacheFlag.CLIENT_STATUS, CacheFlag.EMOJI, CacheFlag.ONLINE_STATUS, + CacheFlag.STICKER, CacheFlag.SCHEDULED_EVENTS) .setActivity(config.isGameNone() ? null : Activity.playing("loading...")) - .setStatus(config.getStatus()==OnlineStatus.INVISIBLE || config.getStatus()==OnlineStatus.OFFLINE - ? OnlineStatus.INVISIBLE : OnlineStatus.DO_NOT_DISTURB) + .setStatus( + config.getStatus() == OnlineStatus.INVISIBLE || config.getStatus() == OnlineStatus.OFFLINE + ? OnlineStatus.INVISIBLE + : OnlineStatus.DO_NOT_DISTURB) .addEventListeners(client, waiter, new Listener(bot)) .setBulkDeleteSplittingEnabled(true) + .setAudioModuleConfig(new AudioModuleConfig() + .withDaveSessionFactory(new JDaveSessionFactory())) .build(); bot.setJDA(jda); // check if something about the current startup is not supported String unsupportedReason = OtherUtil.getUnsupportedBotReason(jda); - if (unsupportedReason != null) - { - prompt.alert(Prompt.Level.ERROR, "JMusicBot", "JMusicBot cannot be run on this Discord bot: " + unsupportedReason); - try{ Thread.sleep(5000);}catch(InterruptedException ignored){} // this is awful but until we have a better way... + if (unsupportedReason != null) { + prompt.alert(Prompt.Level.ERROR, "JMusicBot", + "JMusicBot cannot be run on this Discord bot: " + unsupportedReason); + try { + Thread.sleep(5000); + } catch (InterruptedException ignored) { + } // this is awful but until we have a better way... jda.shutdown(); System.exit(1); } - + // other check that will just be a warning now but may be required in the future - // check if the user has changed the prefix and provide info about the + // check if the user has changed the prefix and provide info about the // message content intent - if(!"@mention".equals(config.getPrefix())) - { + if (!"@mention".equals(config.getPrefix())) { LOG.info("JMusicBot", "You currently have a custom prefix set. " + "If your prefix is not working, make sure that the 'MESSAGE CONTENT INTENT' is Enabled " + "on https://discord.com/developers/applications/" + jda.getSelfUser().getId() + "/bot"); } - } - catch (LoginException ex) - { - prompt.alert(Prompt.Level.ERROR, "JMusicBot", ex + "\nPlease make sure you are " - + "editing the correct config.txt file, and that you have used the " - + "correct token (not the 'secret'!)\nConfig Location: " + config.getConfigLocation()); - System.exit(1); - } - catch(IllegalArgumentException ex) - { + } catch (IllegalArgumentException ex) { prompt.alert(Prompt.Level.ERROR, "JMusicBot", "Some aspect of the configuration is " + "invalid: " + ex + "\nConfig Location: " + config.getConfigLocation()); System.exit(1); - } - catch(ErrorResponseException ex) - { + } catch (ErrorResponseException ex) { prompt.alert(Prompt.Level.ERROR, "JMusicBot", ex + "\nInvalid reponse returned when " + "attempting to connect, please make sure you're connected to the internet"); System.exit(1); } } - - private static CommandClient createCommandClient(BotConfig config, SettingsManager settings, Bot bot) - { + + private static CommandClient createCommandClient(BotConfig config, SettingsManager settings, Bot bot) { // instantiate about command AboutCommand aboutCommand = new AboutCommand(Color.BLUE.brighter(), - "a music bot that is [easy to host yourself!](https://github.com/jagrosh/MusicBot) (v" + OtherUtil.getCurrentVersion() + ")", - new String[]{"High-quality music playback", "FairQueue™ Technology", "Easy to host yourself"}, - RECOMMENDED_PERMS); + "a music bot that is [easy to host yourself!](https://github.com/jagrosh/MusicBot) (v" + + OtherUtil.getCurrentVersion() + ")", + new String[] { "High-quality music playback", "FairQueue™ Technology", "Easy to host yourself" }, + RECOMMENDED_PERMS); aboutCommand.setIsAuthor(false); aboutCommand.setReplacementCharacter("\uD83C\uDFB6"); // 🎶 - + // set up the command client CommandClientBuilder cb = new CommandClientBuilder() .setPrefix(config.getPrefix()) @@ -190,7 +180,7 @@ public class JMusicBot .addCommands(aboutCommand, new PingCommand(), new SettingsCmd(bot), - + new LyricsCmd(bot), new NowplayingCmd(bot), new PlayCmd(bot), @@ -212,7 +202,7 @@ public class JMusicBot new SkiptoCmd(bot), new StopCmd(bot), new VolumeCmd(bot), - + new PrefixCmd(bot), new QueueTypeCmd(bot), new SetdjCmd(bot), @@ -227,25 +217,24 @@ public class JMusicBot new SetgameCmd(bot), new SetnameCmd(bot), new SetstatusCmd(bot), - new ShutdownCmd(bot) - ); - + new ShutdownCmd(bot)); + // enable eval if applicable - if(config.useEval()) + if (config.useEval()) cb.addCommand(new EvalCmd(bot)); - + // set status if set in config - if(config.getStatus() != OnlineStatus.UNKNOWN) + if (config.getStatus() != OnlineStatus.UNKNOWN) cb.setStatus(config.getStatus()); - + // set game - if(config.getGame() == null) + if (config.getGame() == null) cb.useDefaultGame(); - else if(config.isGameNone()) + else if (config.isGameNone()) cb.setActivity(null); else cb.setActivity(config.getGame()); - + return cb.build(); } } diff --git a/src/main/java/com/jagrosh/jmusicbot/Listener.java b/src/main/java/com/jagrosh/jmusicbot/Listener.java index 2e50b79..2a22d4a 100644 --- a/src/main/java/com/jagrosh/jmusicbot/Listener.java +++ b/src/main/java/com/jagrosh/jmusicbot/Listener.java @@ -20,12 +20,12 @@ import java.util.concurrent.TimeUnit; import net.dv8tion.jda.api.JDA; import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.User; -import net.dv8tion.jda.api.entities.VoiceChannel; -import net.dv8tion.jda.api.events.ReadyEvent; -import net.dv8tion.jda.api.events.ShutdownEvent; +import net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel; import net.dv8tion.jda.api.events.guild.GuildJoinEvent; import net.dv8tion.jda.api.events.guild.voice.GuildVoiceUpdateEvent; -import net.dv8tion.jda.api.events.message.guild.GuildMessageDeleteEvent; +import net.dv8tion.jda.api.events.message.MessageDeleteEvent; +import net.dv8tion.jda.api.events.session.ReadyEvent; +import net.dv8tion.jda.api.events.session.ShutdownEvent; import net.dv8tion.jda.api.hooks.ListenerAdapter; import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; @@ -85,10 +85,11 @@ public class Listener extends ListenerAdapter catch(Exception ignored) {} // ignored }, 0, 24, TimeUnit.HOURS); } + bot.resetGame(); } @Override - public void onGuildMessageDelete(GuildMessageDeleteEvent event) + public void onMessageDelete(MessageDeleteEvent event) { bot.getNowplayingHandler().onMessageDelete(event.getGuild(), event.getMessageIdLong()); } diff --git a/src/main/java/com/jagrosh/jmusicbot/audio/AudioHandler.java b/src/main/java/com/jagrosh/jmusicbot/audio/AudioHandler.java index e5b93fc..ef6cd88 100644 --- a/src/main/java/com/jagrosh/jmusicbot/audio/AudioHandler.java +++ b/src/main/java/com/jagrosh/jmusicbot/audio/AudioHandler.java @@ -36,11 +36,11 @@ import com.sedmelluq.discord.lavaplayer.source.youtube.YoutubeAudioTrack; import java.nio.ByteBuffer; import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.JDA; -import net.dv8tion.jda.api.MessageBuilder; import net.dv8tion.jda.api.audio.AudioSendHandler; import net.dv8tion.jda.api.entities.Guild; -import net.dv8tion.jda.api.entities.Message; import net.dv8tion.jda.api.entities.User; +import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder; +import net.dv8tion.jda.api.utils.messages.MessageCreateData; import org.slf4j.LoggerFactory; /** @@ -118,7 +118,7 @@ public class AudioHandler extends AudioEventAdapter implements AudioSendHandler public boolean isMusicPlaying(JDA jda) { - return guild(jda).getSelfMember().getVoiceState().inVoiceChannel() && audioPlayer.getPlayingTrack()!=null; + return guild(jda).getSelfMember().getVoiceState().inAudioChannel() && audioPlayer.getPlayingTrack()!=null; } public Set getVotes() @@ -215,14 +215,14 @@ public class AudioHandler extends AudioEventAdapter implements AudioSendHandler // Formatting - public Message getNowPlaying(JDA jda) + public MessageCreateData getNowPlaying(JDA jda) { if(isMusicPlaying(jda)) { Guild guild = guild(jda); AudioTrack track = audioPlayer.getPlayingTrack(); - MessageBuilder mb = new MessageBuilder(); - mb.append(FormatUtil.filter(manager.getBot().getConfig().getSuccess()+" **Now Playing in "+guild.getSelfMember().getVoiceState().getChannel().getAsMention()+"...**")); + MessageCreateBuilder mb = new MessageCreateBuilder(); + mb.setContent(FormatUtil.filter(manager.getBot().getConfig().getSuccess()+" **Now Playing in "+guild.getSelfMember().getVoiceState().getChannel().getAsMention()+"...**")); EmbedBuilder eb = new EmbedBuilder(); eb.setColor(guild.getSelfMember().getColor()); RequestMetadata rm = getRequestMetadata(); @@ -263,10 +263,10 @@ public class AudioHandler extends AudioEventAdapter implements AudioSendHandler else return null; } - public Message getNoMusicPlaying(JDA jda) + public MessageCreateData getNoMusicPlaying(JDA jda) { Guild guild = guild(jda); - return new MessageBuilder() + return new MessageCreateBuilder() .setContent(FormatUtil.filter(manager.getBot().getConfig().getSuccess()+" **Now Playing...**")) .setEmbeds(new EmbedBuilder() .setTitle("No music playing") diff --git a/src/main/java/com/jagrosh/jmusicbot/audio/NowplayingHandler.java b/src/main/java/com/jagrosh/jmusicbot/audio/NowplayingHandler.java index e09e3e6..1c84529 100644 --- a/src/main/java/com/jagrosh/jmusicbot/audio/NowplayingHandler.java +++ b/src/main/java/com/jagrosh/jmusicbot/audio/NowplayingHandler.java @@ -27,9 +27,9 @@ import net.dv8tion.jda.api.Permission; import net.dv8tion.jda.api.entities.Activity; import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.Message; -import net.dv8tion.jda.api.entities.TextChannel; -import net.dv8tion.jda.api.exceptions.PermissionException; -import net.dv8tion.jda.api.exceptions.RateLimitedException; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; +import net.dv8tion.jda.api.utils.messages.MessageCreateData; +import net.dv8tion.jda.api.utils.messages.MessageEditData; /** * @@ -54,7 +54,7 @@ public class NowplayingHandler public void setLastNPMessage(Message m) { - lastNP.put(m.getGuild().getIdLong(), new Pair<>(m.getTextChannel().getIdLong(), m.getIdLong())); + lastNP.put(m.getGuild().getIdLong(), new Pair<>(m.getChannelIdLong(), m.getIdLong())); } public void clearLastNPMessage(Guild guild) @@ -81,7 +81,7 @@ public class NowplayingHandler continue; } AudioHandler handler = (AudioHandler)guild.getAudioManager().getSendingHandler(); - Message msg = handler.getNowPlaying(bot.getJDA()); + MessageCreateData msg = handler.getNowPlaying(bot.getJDA()); if(msg==null) { msg = handler.getNoMusicPlaying(bot.getJDA()); @@ -89,7 +89,7 @@ public class NowplayingHandler } try { - tc.editMessageById(pair.getValue(), msg).queue(m->{}, t -> lastNP.remove(guildId)); + tc.editMessageById(pair.getValue(), MessageEditData.fromCreateData(msg)).queue(m->{}, t -> lastNP.remove(guildId)); } catch(Exception e) { @@ -105,7 +105,7 @@ public class NowplayingHandler // update bot status if applicable if(bot.getConfig().getSongInStatus()) { - if(track!=null && bot.getJDA().getGuilds().stream().filter(g -> g.getSelfMember().getVoiceState().inVoiceChannel()).count()<=1) + if(track!=null && bot.getJDA().getGuilds().stream().filter(g -> g.getSelfMember().getVoiceState().inAudioChannel()).count()<=1) bot.getJDA().getPresence().setActivity(Activity.listening(track.getInfo().title)); else bot.resetGame(); diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/MusicCommand.java b/src/main/java/com/jagrosh/jmusicbot/commands/MusicCommand.java index 9740a7a..0c16480 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/MusicCommand.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/MusicCommand.java @@ -21,8 +21,9 @@ import com.jagrosh.jmusicbot.Bot; import com.jagrosh.jmusicbot.settings.Settings; import com.jagrosh.jmusicbot.audio.AudioHandler; 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; +import net.dv8tion.jda.api.entities.channel.middleman.AudioChannel; import net.dv8tion.jda.api.exceptions.PermissionException; /** @@ -64,11 +65,11 @@ public abstract class MusicCommand extends Command } if(beListening) { - VoiceChannel current = event.getGuild().getSelfMember().getVoiceState().getChannel(); + AudioChannel current = event.getGuild().getSelfMember().getVoiceState().getChannel(); if(current==null) current = settings.getVoiceChannel(event.getGuild()); GuildVoiceState userState = event.getMember().getVoiceState(); - if(!userState.inVoiceChannel() || userState.isDeafened() || (current!=null && !userState.getChannel().equals(current))) + if(!userState.inAudioChannel() || userState.isDeafened() || (current!=null && !userState.getChannel().equals(current))) { event.replyError("You must be listening in "+(current==null ? "a voice channel" : current.getAsMention())+" to use that!"); return; @@ -81,7 +82,7 @@ public abstract class MusicCommand extends Command return; } - if(!event.getGuild().getSelfMember().getVoiceState().inVoiceChannel()) + if(!event.getGuild().getSelfMember().getVoiceState().inAudioChannel()) { try { diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/admin/SettcCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/admin/SettcCmd.java index 568085d..a039a94 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/admin/SettcCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/admin/SettcCmd.java @@ -22,7 +22,7 @@ import com.jagrosh.jmusicbot.Bot; import com.jagrosh.jmusicbot.commands.AdminCommand; import com.jagrosh.jmusicbot.settings.Settings; import com.jagrosh.jmusicbot.utils.FormatUtil; -import net.dv8tion.jda.api.entities.TextChannel; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; /** * diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetvcCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetvcCmd.java index e8f6663..c06a3a8 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetvcCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetvcCmd.java @@ -22,7 +22,7 @@ import com.jagrosh.jmusicbot.Bot; import com.jagrosh.jmusicbot.commands.AdminCommand; import com.jagrosh.jmusicbot.settings.Settings; import com.jagrosh.jmusicbot.utils.FormatUtil; -import net.dv8tion.jda.api.entities.VoiceChannel; +import net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel; /** * diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/general/SettingsCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/general/SettingsCmd.java index a013983..2fea579 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/general/SettingsCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/general/SettingsCmd.java @@ -23,10 +23,10 @@ import com.jagrosh.jmusicbot.settings.RepeatMode; import com.jagrosh.jmusicbot.settings.Settings; import com.jagrosh.jmusicbot.utils.FormatUtil; import net.dv8tion.jda.api.EmbedBuilder; -import net.dv8tion.jda.api.MessageBuilder; import net.dv8tion.jda.api.entities.Role; -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; +import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder; /** * @@ -48,10 +48,10 @@ public class SettingsCmd extends Command protected void execute(CommandEvent event) { Settings s = event.getClient().getSettingsFor(event.getGuild()); - MessageBuilder builder = new MessageBuilder() - .append(EMOJI + " **") - .append(FormatUtil.filter(event.getSelfUser().getName())) - .append("** settings:"); + MessageCreateBuilder builder = new MessageCreateBuilder() + .addContent(EMOJI + " **") + .addContent(FormatUtil.filter(event.getSelfUser().getName())) + .addContent("** settings:"); TextChannel tchan = s.getTextChannel(event.getGuild()); VoiceChannel vchan = s.getVoiceChannel(event.getGuild()); Role role = s.getRole(event.getGuild()); @@ -70,7 +70,7 @@ public class SettingsCmd extends Command + "\nDefault Playlist: " + (s.getDefaultPlaylist() == null ? "None" : "**" + s.getDefaultPlaylist() + "**") ) .setFooter(event.getJDA().getGuilds().size() + " servers | " - + event.getJDA().getGuilds().stream().filter(g -> g.getSelfMember().getVoiceState().inVoiceChannel()).count() + + event.getJDA().getGuilds().stream().filter(g -> g.getSelfMember().getVoiceState().inAudioChannel()).count() + " audio connections", null); event.getChannel().sendMessage(builder.setEmbeds(ebuilder.build()).build()).queue(); } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/music/NowplayingCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/music/NowplayingCmd.java index 9a28cba..cac7fce 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/music/NowplayingCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/music/NowplayingCmd.java @@ -20,7 +20,7 @@ import com.jagrosh.jmusicbot.Bot; import com.jagrosh.jmusicbot.audio.AudioHandler; import com.jagrosh.jmusicbot.commands.MusicCommand; import net.dv8tion.jda.api.Permission; -import net.dv8tion.jda.api.entities.Message; +import net.dv8tion.jda.api.utils.messages.MessageCreateData; /** * @@ -41,7 +41,7 @@ public class NowplayingCmd extends MusicCommand public void doCommand(CommandEvent event) { AudioHandler handler = (AudioHandler)event.getGuild().getAudioManager().getSendingHandler(); - Message m = handler.getNowPlaying(event.getJDA()); + MessageCreateData m = handler.getNowPlaying(event.getJDA()); if(m==null) { event.reply(handler.getNoMusicPlaying(event.getJDA())); diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/music/QueueCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/music/QueueCmd.java index 3516812..2f98292 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/music/QueueCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/music/QueueCmd.java @@ -28,10 +28,10 @@ import com.jagrosh.jmusicbot.settings.RepeatMode; import com.jagrosh.jmusicbot.settings.Settings; import com.jagrosh.jmusicbot.utils.FormatUtil; import com.jagrosh.jmusicbot.utils.TimeUtil; -import net.dv8tion.jda.api.MessageBuilder; import net.dv8tion.jda.api.Permission; -import net.dv8tion.jda.api.entities.Message; import net.dv8tion.jda.api.exceptions.PermissionException; +import net.dv8tion.jda.api.utils.messages.MessageCreateBuilder; +import net.dv8tion.jda.api.utils.messages.MessageCreateData; /** * @@ -75,9 +75,9 @@ public class QueueCmd extends MusicCommand List list = ah.getQueue().getList(); if(list.isEmpty()) { - Message nowp = ah.getNowPlaying(event.getJDA()); - Message nonowp = ah.getNoMusicPlaying(event.getJDA()); - Message built = new MessageBuilder() + MessageCreateData nowp = ah.getNowPlaying(event.getJDA()); + MessageCreateData nonowp = ah.getNoMusicPlaying(event.getJDA()); + MessageCreateData built = new MessageCreateBuilder() .setContent(event.getClient().getWarning() + " There is no music in the queue!") .setEmbeds((nowp==null ? nonowp : nowp).getEmbeds().get(0)).build(); event.reply(built, m -> diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/owner/DebugCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/owner/DebugCmd.java index 829955d..79b6b23 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/owner/DebugCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/owner/DebugCmd.java @@ -23,7 +23,8 @@ import com.jagrosh.jmusicbot.utils.OtherUtil; import com.sedmelluq.discord.lavaplayer.tools.PlayerLibrary; import net.dv8tion.jda.api.JDAInfo; 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.utils.FileUpload; /** * @@ -80,8 +81,8 @@ public class DebugCmd extends OwnerCommand if(event.isFromType(ChannelType.PRIVATE) || event.getSelfMember().hasPermission(event.getTextChannel(), Permission.MESSAGE_ATTACH_FILES)) - event.getChannel().sendFile(sb.toString().getBytes(), "debug_information.txt").queue(); + event.getChannel().sendFiles(FileUpload.fromData(sb.toString().getBytes(), "debug_information.txt")).queue(); else - event.reply("Debug Information: " + sb.toString()); + event.reply("Debug Information: " + sb); } } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/owner/EvalCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/owner/EvalCmd.java index 8143f07..7844295 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/owner/EvalCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/owner/EvalCmd.java @@ -20,7 +20,7 @@ import javax.script.ScriptEngineManager; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; import com.jagrosh.jmusicbot.commands.OwnerCommand; -import net.dv8tion.jda.api.entities.ChannelType; +import net.dv8tion.jda.api.entities.channel.ChannelType; /** * diff --git a/src/main/java/com/jagrosh/jmusicbot/settings/Settings.java b/src/main/java/com/jagrosh/jmusicbot/settings/Settings.java index d9fb845..fdf51f3 100644 --- a/src/main/java/com/jagrosh/jmusicbot/settings/Settings.java +++ b/src/main/java/com/jagrosh/jmusicbot/settings/Settings.java @@ -20,8 +20,8 @@ import java.util.Collection; import java.util.Collections; import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.Role; -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; /** * diff --git a/src/main/java/com/jagrosh/jmusicbot/utils/FormatUtil.java b/src/main/java/com/jagrosh/jmusicbot/utils/FormatUtil.java index 2921eed..eb998df 100644 --- a/src/main/java/com/jagrosh/jmusicbot/utils/FormatUtil.java +++ b/src/main/java/com/jagrosh/jmusicbot/utils/FormatUtil.java @@ -18,9 +18,9 @@ package com.jagrosh.jmusicbot.utils; import com.jagrosh.jmusicbot.audio.RequestMetadata.UserInfo; import java.util.List; import net.dv8tion.jda.api.entities.Role; -import net.dv8tion.jda.api.entities.TextChannel; +import net.dv8tion.jda.api.entities.channel.concrete.TextChannel; import net.dv8tion.jda.api.entities.User; -import net.dv8tion.jda.api.entities.VoiceChannel; +import net.dv8tion.jda.api.entities.channel.concrete.VoiceChannel; /** *