From eb3a5d2990aef53d70456d502bcc9666f6685e2e Mon Sep 17 00:00:00 2001 From: thmsdy Date: Wed, 22 Jul 2020 23:13:27 -0500 Subject: [PATCH] Bot will seach for another video if the selected video cannot be played --- .../biscuit/audio/AudioResultHandler.java | 69 +++++----------- .../fpghoti/biscuit/audio/AudioScheduler.java | 79 +++++++------------ .../biscuit/audio/queue/AudioQueue.java | 21 ++++- .../biscuit/audio/queue/QueuedTrack.java | 77 ++++++++++++++++-- .../biscuit/commands/CommandManager.java | 52 ++++++------ .../biscuit/commands/base/ClientCommand.java | 3 +- .../biscuit/commands/base/CustomCommand.java | 4 +- .../commands/base/MusicClientCommand.java | 4 +- .../biscuit/commands/client/AddCommand.java | 6 +- .../commands/client/ChanIDCommand.java | 8 +- .../commands/client/DivideCommand.java | 6 +- .../commands/client/ForceSkipCommand.java | 10 ++- .../commands/client/GetConfigCommand.java | 8 +- .../commands/client/GuildIDCommand.java | 6 +- .../biscuit/commands/client/HelpCommand.java | 12 +-- .../commands/client/LoopMusicCommand.java | 4 +- .../commands/client/MakeInviteCommand.java | 4 +- .../commands/client/MultiplyCommand.java | 6 +- .../commands/client/NotSpammerCommand.java | 6 +- .../commands/client/NowPlayingCommand.java | 12 +-- .../biscuit/commands/client/PauseCommand.java | 4 +- .../biscuit/commands/client/PingCommand.java | 6 +- .../biscuit/commands/client/PlayCommand.java | 8 +- .../commands/client/PlayFirstCommand.java | 8 +- .../biscuit/commands/client/PowerCommand.java | 6 +- .../biscuit/commands/client/QueueCommand.java | 16 ++-- .../client/RecentSpammersCommand.java | 6 +- .../commands/client/SaveConfigCommand.java | 12 +-- .../biscuit/commands/client/SkipCommand.java | 20 +++-- .../commands/client/SoftMuteCommand.java | 8 +- .../commands/client/SquareRootCommand.java | 6 +- .../commands/client/SubtractCommand.java | 6 +- .../commands/client/TogglePauseCommand.java | 4 +- .../commands/client/ToggleRoleCommand.java | 6 +- .../biscuit/commands/client/UIDCommand.java | 6 +- .../commands/client/UnSoftMuteCommand.java | 6 +- .../commands/client/UnpauseCommand.java | 4 +- .../biscuit/commands/client/WikiCommand.java | 6 +- .../commands/client/WipeQueueCommand.java | 4 +- .../biscuit/listener/CommandListener.java | 9 +-- 40 files changed, 293 insertions(+), 255 deletions(-) diff --git a/src/main/java/com/fpghoti/biscuit/audio/AudioResultHandler.java b/src/main/java/com/fpghoti/biscuit/audio/AudioResultHandler.java index 55355bd..ca14c39 100644 --- a/src/main/java/com/fpghoti/biscuit/audio/AudioResultHandler.java +++ b/src/main/java/com/fpghoti/biscuit/audio/AudioResultHandler.java @@ -2,7 +2,6 @@ package com.fpghoti.biscuit.audio; import com.fpghoti.biscuit.Main; import com.fpghoti.biscuit.biscuit.Biscuit; -import com.fpghoti.biscuit.util.Util; import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler; import com.sedmelluq.discord.lavaplayer.tools.FriendlyException; import com.sedmelluq.discord.lavaplayer.track.AudioPlaylist; @@ -18,78 +17,48 @@ public class AudioResultHandler implements AudioLoadResultHandler { private String searchPhrase; private boolean search; private boolean first; - private boolean stop; - - public AudioResultHandler(Biscuit biscuit, String uid, TextChannel channel, boolean search, - String searchPhrase, boolean first, boolean stop) { - this.biscuit = biscuit; + private boolean playAfterQueue; + + public AudioResultHandler(String uid, TextChannel channel, boolean search, String searchPhrase, boolean first, boolean playAfterQueue) { + this.biscuit = Biscuit.getBiscuit(channel.getGuild()); this.uid = uid; this.channel = channel; this.search = search; this.searchPhrase = searchPhrase; this.first = first; - this.stop = stop; - } - - public AudioResultHandler(Biscuit biscuit, String uid, TextChannel channel, boolean search, - String searchPhrase, boolean first) { - this.biscuit = biscuit; - this.uid = uid; - this.channel = channel; - this.search = search; - this.searchPhrase = searchPhrase; - this.first = first; - this.stop = false; - } - - public AudioResultHandler(Biscuit biscuit, String uid, TextChannel channel, boolean search, String searchPhrase) { - this.biscuit = biscuit; - this.uid = uid; - this.channel = channel; - this.search = search; - this.searchPhrase = searchPhrase; - this.first = false; - this.stop = false; + this.playAfterQueue = playAfterQueue; } @Override public void trackLoaded(AudioTrack track) { - if(!stop) { - //TODO fix vevo - //Try to avoid Vevo results if possible. - String title = track.getInfo().title; - if(title.toLowerCase().contains("vevo") || track.getInfo().author.toLowerCase().contains("vevo")) { - title = title.toLowerCase().replace("vevo", "") + " lyrics"; - channel.sendMessage("You tried to load a Vevo video. These are not compatible with the music player." - + " Trying to find alternate song...").queue(); - Main.getPlayerManager().loadItemOrdered(biscuit.getGuild(),"ytsearch:" + title, new AudioResultHandler(biscuit, uid, channel, true, title, first, true)); - return; - } - } - - channel.sendMessage("**Adding to queue: **\n```" + track.getInfo().title + "\nBy: " - + track.getInfo().author + "\nLength: " + Util.getTime(track.getDuration()) +"```").queue(); if(first) { - biscuit.getAudioScheduler().queueFirst(track, uid, channel); + biscuit.getAudioScheduler().queue(track, uid, channel, 1); }else { biscuit.getAudioScheduler().queue(track, uid, channel); } + if(playAfterQueue) { + biscuit.getAudioScheduler().startPlaying(); + } } @Override public void playlistLoaded(AudioPlaylist playlist) { AudioTrack track = playlist.getTracks().get(0); - channel.sendMessage("**Adding to queue: **\n" + track.getInfo().uri + "\n```" + track.getInfo().title + "\nBy: " - + track.getInfo().author + "\nLength: " + Util.getTime(track.getDuration()) +"```").queue(); - biscuit.getAudioScheduler().queue(track, uid); + if(first) { + biscuit.getAudioScheduler().queue(track, uid, channel, 1); + }else { + biscuit.getAudioScheduler().queue(track, uid, channel); + } + if(playAfterQueue) { + biscuit.getAudioScheduler().startPlaying(); + } } - @Override public void noMatches() { if(!search) { biscuit.log("Exact match not found. Searching instead..."); - Main.getPlayerManager().loadItemOrdered(biscuit.getGuild(),"ytsearch:" + searchPhrase, new AudioResultHandler(biscuit, uid, channel, true, searchPhrase)); + Main.getPlayerManager().loadItemOrdered(biscuit.getGuild(),"ytsearch:" + searchPhrase, new AudioResultHandler(uid, channel, true, searchPhrase, first, false)); }else { channel.sendMessage("Song match not found.").queue(); } @@ -100,5 +69,7 @@ public class AudioResultHandler implements AudioLoadResultHandler { exception.printStackTrace(); channel.sendMessage("An error was encountered while attempting to load audio.").queue(); } + + } diff --git a/src/main/java/com/fpghoti/biscuit/audio/AudioScheduler.java b/src/main/java/com/fpghoti/biscuit/audio/AudioScheduler.java index 63bcbd1..0362aa1 100644 --- a/src/main/java/com/fpghoti/biscuit/audio/AudioScheduler.java +++ b/src/main/java/com/fpghoti/biscuit/audio/AudioScheduler.java @@ -2,10 +2,10 @@ package com.fpghoti.biscuit.audio; import java.util.ArrayList; +import com.fpghoti.biscuit.Main; import com.fpghoti.biscuit.audio.queue.AudioQueue; import com.fpghoti.biscuit.audio.queue.QueuedTrack; import com.fpghoti.biscuit.biscuit.Biscuit; -import com.fpghoti.biscuit.util.Util; import com.sedmelluq.discord.lavaplayer.player.AudioPlayer; import com.sedmelluq.discord.lavaplayer.player.event.AudioEventAdapter; import com.sedmelluq.discord.lavaplayer.tools.FriendlyException; @@ -52,9 +52,15 @@ public class AudioScheduler extends AudioEventAdapter { switch(endReason) { case LOAD_FAILED: - warn("Something went wrong while trying to load the current track. The next track will be played instead if available."); - if(qt != null && qt.getCommandChannel() != null) - qt.getCommandChannel().sendMessage("There was an error loading **" + title + "**.").queue(); + warn("Something went wrong while trying to load the current track. Trying alternate track."); + if(!qt.triedAlternative()) { + qt.useAttempt(); + TextChannel channel = qt.getCommandChannel(); + channel.sendMessage("The video selected cannot be played through the music player. An alternate track will be played if available.").queue(); + title = title.toLowerCase().replace("vevo", "") + " lyrics"; + Main.getPlayerManager().loadItemOrdered(biscuit.getGuild(),"ytsearch:" + title, new AudioResultHandler(qt.getUserId(), channel, true, title, true, !queue.isEmpty())); + return; + } break; case CLEANUP: log("A track stopped playing due to audio player cleanup."); @@ -77,7 +83,7 @@ public class AudioScheduler extends AudioEventAdapter { if (endReason.mayStartNext) { if(loop) { - queueFirst(track.makeClone(), qt.getUserId(), qt.getCommandChannel()); + queue(track.makeClone(), qt.getUserId(), qt.getCommandChannel(), 1); } startPlaying(); } @@ -85,12 +91,11 @@ public class AudioScheduler extends AudioEventAdapter { @Override public void onTrackException(AudioPlayer player, AudioTrack track, FriendlyException exception) { - //TODO fix vevo - if(track.getInfo().title.toLowerCase().contains("vevo") || track.getInfo().author.toLowerCase().contains("vevo")) { - QueuedTrack qt = queue.getPreviousTrack(track); - qt.getCommandChannel().sendMessage("**" + track.getInfo().title + "** could not be loaded, because it is a Vevo video.").queue(); + QueuedTrack qt = queue.getPreviousTrack(track); + if(!qt.triedAlternative()) { + return; } - biscuit.error("An exception occurred while trying to play a certain track. The next track will be played instead if available."); + warn("No alternative track found. This means the video is most likely unavailable. The next track will be played instead if available."); startPlaying(); } @@ -102,25 +107,22 @@ public class AudioScheduler extends AudioEventAdapter { } } - public void queue(AudioTrack track, String uid) { - queue(track, uid, null); + public void queue(AudioTrack track, String uid, TextChannel channel) { + queue(track, uid, channel, null); } - public void queue(AudioTrack track, String uid, TextChannel channel) { + public void queue(AudioTrack track, String uid, TextChannel channel, Integer place) { if(queue.isEmpty() && biscuit.getAudioPlayer().getPlayingTrack() == null) { - queue.addPreviousTrack(new QueuedTrack(biscuit, track, uid, channel)); + QueuedTrack qt = new QueuedTrack(biscuit, track, uid, channel); + queue.sendQueueMessage(qt); + queue.addPreviousTrack(qt); biscuit.getAudioPlayer().playTrack(track); }else { - queue.add(new QueuedTrack(biscuit, track, uid, channel)); - } - } - - public void queueFirst(AudioTrack track, String uid, TextChannel channel) { - if(queue.isEmpty() && biscuit.getAudioPlayer().getPlayingTrack() == null) { - queue.addPreviousTrack(new QueuedTrack(biscuit, track, uid, channel)); - biscuit.getAudioPlayer().playTrack(track); - }else { - queue.addAtPlace(new QueuedTrack(biscuit, track, uid, channel), 1); + if(place != null) { + queue.addAtPlace(new QueuedTrack(biscuit, track, uid, channel), place); + }else { + queue.add(new QueuedTrack(biscuit, track, uid, channel)); + } } } @@ -128,7 +130,7 @@ public class AudioScheduler extends AudioEventAdapter { if(queue.isEmpty()) { if(loop) { return; - } + } biscuit.getGuild().getAudioManager().closeAudioConnection(); skips.clear(); return; @@ -136,11 +138,11 @@ public class AudioScheduler extends AudioEventAdapter { queue.playNext(); skips.clear(); } - + public void setLooping(boolean b) { loop = b; } - + public boolean isLooping() { return loop; } @@ -170,29 +172,6 @@ public class AudioScheduler extends AudioEventAdapter { startPlaying(); } - public String getNextMessage() { - if(queue.isEmpty()) { - return null; - } - AudioTrack track = queue.getNext().getTrack(); - return getMessage(track); - } - - public String getMessage(AudioTrack track) { - return getMessage(track, false); - } - - public String getMessage(AudioTrack track, Boolean showRemaining) { - String msg ="**Now Playing: **\n" + track.getInfo().uri + "\n```" + track.getInfo().title + "\nBy: " - + track.getInfo().author + "\nLength: " + Util.getTime(track.getDuration()); - if(showRemaining) { - msg = msg + "\nTime Remaining: " + Util.getTime(track.getDuration() - track.getPosition()) + "```"; - }else { - msg = msg + "```"; - } - return msg; - } - public void wipeQueue() { queue.clear(); } diff --git a/src/main/java/com/fpghoti/biscuit/audio/queue/AudioQueue.java b/src/main/java/com/fpghoti/biscuit/audio/queue/AudioQueue.java index 94a3450..a21be4d 100644 --- a/src/main/java/com/fpghoti/biscuit/audio/queue/AudioQueue.java +++ b/src/main/java/com/fpghoti/biscuit/audio/queue/AudioQueue.java @@ -4,6 +4,9 @@ import java.util.ArrayList; import com.sedmelluq.discord.lavaplayer.track.AudioTrack; +import net.dv8tion.jda.api.entities.MessageEmbed; +import net.dv8tion.jda.api.entities.TextChannel; + public class AudioQueue { private ArrayList tracks; @@ -77,19 +80,32 @@ public class AudioQueue { } public void add(QueuedTrack track) { + sendQueueMessage(track); tracks.add(track); } //Goes by viewable place rather than index for //easy implementation into command. public boolean addAtPlace(QueuedTrack track, int place) { - if(place < 1 || place > tracks.size()) { + if(place < 1) { return false; } int index = place - 1; + if(index > tracks.size()) { + index = tracks.size(); + } + sendQueueMessage(track); tracks.add(index, track); return true; } + + public void sendQueueMessage(QueuedTrack track) { + if(track.getCommandChannel() != null) { + TextChannel c = track.getCommandChannel(); + MessageEmbed m = track.getEmbedMessage("Queued:"); + c.sendMessage(m).queue(); + } + } //Goes by viewable place rather than index for //easy implementation into command. @@ -114,6 +130,9 @@ public class AudioQueue { } public QueuedTrack getNext() { + if(isEmpty()) { + return null; + } return tracks.get(0); } diff --git a/src/main/java/com/fpghoti/biscuit/audio/queue/QueuedTrack.java b/src/main/java/com/fpghoti/biscuit/audio/queue/QueuedTrack.java index 8b8fdcf..b0d9442 100644 --- a/src/main/java/com/fpghoti/biscuit/audio/queue/QueuedTrack.java +++ b/src/main/java/com/fpghoti/biscuit/audio/queue/QueuedTrack.java @@ -1,43 +1,106 @@ package com.fpghoti.biscuit.audio.queue; +import java.awt.Color; + import com.fpghoti.biscuit.biscuit.Biscuit; +import com.fpghoti.biscuit.util.Util; import com.sedmelluq.discord.lavaplayer.track.AudioTrack; +import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.entities.Member; +import net.dv8tion.jda.api.entities.MessageEmbed; import net.dv8tion.jda.api.entities.TextChannel; public class QueuedTrack { - + private Biscuit biscuit; private AudioTrack track; private String userId; private TextChannel channel; - + private boolean triedAlternative; + public QueuedTrack(Biscuit biscuit, AudioTrack track, String userId, TextChannel channel) { this.biscuit = biscuit; this.track = track; this.userId = userId; this.channel = channel; + this.triedAlternative = false; } - + public Biscuit getBiscuit() { return biscuit; } - + public AudioTrack getTrack() { return track; } - + public String getUserId() { return userId; } - + public Member getMember() { return biscuit.getGuild().getMemberById(userId); } - + public TextChannel getCommandChannel() { return channel; } + public MessageEmbed getEmbedMessage(String prefix) { + return getEmbedMessage(prefix, false); + } + + public MessageEmbed getEmbedMessage(String prefix, boolean showRemaining) { + EmbedBuilder embed = new EmbedBuilder(); + + String title = track.getInfo().title; + if(prefix != null && !prefix.equals("")) { + title = prefix + " " + title; + } + + embed.setTitle(title, track.getInfo().uri); + embed.setColor(Color.CYAN); + + String desc = "Author: " + track.getInfo().author + "\nLength: " + Util.getTime(track.getDuration()); + + if(showRemaining) { + desc = desc + "\nTime Remaining: " + Util.getTime(track.getDuration() - track.getPosition()); + } + + embed.setDescription(desc); + + String name = biscuit.getGuild().getSelfMember().getEffectiveName(); + String avatar = biscuit.getGuild().getSelfMember().getUser().getEffectiveAvatarUrl(); + + Member m = getMember(); + if(m != null) { + name = m.getEffectiveName(); + avatar = m.getUser().getEffectiveAvatarUrl(); + } + + embed.setAuthor(name, null, avatar); + + if(isYouTube()) { + embed.setThumbnail("https://img.youtube.com/vi/" + track.getIdentifier() + "/mqdefault.jpg"); + } + + return embed.build(); + } + + + public boolean triedAlternative() { + return triedAlternative; + } + + //Indicates an attempt has been made to search for another video + //Prevent and endless loop + public void useAttempt() { + triedAlternative = true; + } + + public boolean isYouTube() { + return track.getInfo().uri.contains("https://www.youtube.com/watch?v="); + } + } diff --git a/src/main/java/com/fpghoti/biscuit/commands/CommandManager.java b/src/main/java/com/fpghoti/biscuit/commands/CommandManager.java index 164312c..d060bf5 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/CommandManager.java +++ b/src/main/java/com/fpghoti/biscuit/commands/CommandManager.java @@ -12,14 +12,14 @@ import com.fpghoti.biscuit.commands.base.MusicClientCommand; import com.fpghoti.biscuit.util.PermUtil; import com.fpghoti.biscuit.util.Util; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public class CommandManager { private static List commands = new ArrayList(); - public static void parse(String message, MessageReceivedEvent e){ - Biscuit b = Biscuit.getBiscuit(e.getGuild()); + public static void parse(String message, GuildMessageReceivedEvent event){ + Biscuit b = Biscuit.getBiscuit(event.getGuild()); ArrayList split = new ArrayList(); String fixed = message.replaceFirst(b.getProperties().getCommandSignifier(), ""); String[] splitMsg = fixed.split(" "); @@ -30,7 +30,7 @@ public class CommandManager { String[] args = new String[split.size() - 1]; split.subList(1, split.size()).toArray(args); - dispatch(e, label, args); + dispatch(event, label, args); } @@ -38,16 +38,16 @@ public class CommandManager { return dispatch(null,label,args); } - public static boolean dispatch(MessageReceivedEvent e, String label, String[] args) { + public static boolean dispatch(GuildMessageReceivedEvent event, String label, String[] args) { Biscuit b = Main.getMainBiscuit(); boolean isMain = true; - if(e != null) { - b = Biscuit.getBiscuit(e.getGuild()); + if(event != null) { + b = Biscuit.getBiscuit(event.getGuild()); isMain = false; if(Util.contains(b.getProperties().disabledCommands(), label)) { return false; } - if(!PermUtil.isAdmin(e.getMember()) && Util.contains(b.getProperties().disabledUserCommands(), label)) { + if(!PermUtil.isAdmin(event.getMember()) && Util.contains(b.getProperties().disabledUserCommands(), label)) { return false; } @@ -79,17 +79,17 @@ public class CommandManager { } if (trimmedArgs == null || (trimmedArgs.length > 0 && trimmedArgs[0].equals("?"))) { - commandReply(e, "``Command:" + " " + match.getName() + "``"); - commandReply(e, "``Description:" + " " + match.getDescription() + "``"); - commandReply(e, "``Usage:" + " " + match.getUsage() + "``"); + commandReply(event, "``Command:" + " " + match.getName() + "``"); + commandReply(event, "``Description:" + " " + match.getDescription() + "``"); + commandReply(event, "``Usage:" + " " + match.getUsage() + "``"); List notes = match.getNotes(); for (String note : notes) { - commandReply(e, note); + commandReply(event, note); } } else { - if(match instanceof ClientCommand && e != null) { - ((ClientCommand)match).execute(trimmedArgs, e); - }else if(match instanceof ConsoleCommand && e == null) { + if(match instanceof ClientCommand && event != null) { + ((ClientCommand)match).execute(trimmedArgs, event); + }else if(match instanceof ConsoleCommand && event == null) { ((ConsoleCommand)match).execute(trimmedArgs); } } @@ -97,29 +97,29 @@ public class CommandManager { if(Util.contains(Main.getMainBiscuit().getProperties().getCustomCmds(), label)) { CustomCommand cc = new CustomCommand(label, Main.getMainBiscuit()); if(args.length >= 1) { - commandReply(e, "``Command:" + " " + cc.getName() + "``"); - commandReply(e, "``Description:" + " " + cc.getDescription() + "``"); - commandReply(e, "``Usage:" + " " + cc.getUsage() + "``"); + commandReply(event, "``Command:" + " " + cc.getName() + "``"); + commandReply(event, "``Description:" + " " + cc.getDescription() + "``"); + commandReply(event, "``Usage:" + " " + cc.getUsage() + "``"); }else { - commandReply(e, CustomCommand.fixPlaceholders(e, cc.getMessage())); + commandReply(event, CustomCommand.fixPlaceholders(event, cc.getMessage())); } }else if(!isMain && Util.contains(b.getProperties().getCustomCmds(), label)) { CustomCommand cc = new CustomCommand(label, b); if(args.length >= 1) { - commandReply(e, "``Command:" + " " + cc.getName() + "``"); - commandReply(e, "``Description:" + " " + cc.getDescription() + "``"); - commandReply(e, "``Usage:" + " " + cc.getUsage() + "``"); + commandReply(event, "``Command:" + " " + cc.getName() + "``"); + commandReply(event, "``Description:" + " " + cc.getDescription() + "``"); + commandReply(event, "``Usage:" + " " + cc.getUsage() + "``"); }else { - commandReply(e, CustomCommand.fixPlaceholders(e, cc.getMessage())); + commandReply(event, CustomCommand.fixPlaceholders(event, cc.getMessage())); } } } return true; } - public static void commandReply(MessageReceivedEvent e, String msg) { - if(e != null) { - e.getTextChannel().sendMessage(msg).queue(); + public static void commandReply(GuildMessageReceivedEvent event, String msg) { + if(event != null) { + event.getChannel().sendMessage(msg).queue(); }else { Main.getLogger().info(msg); } diff --git a/src/main/java/com/fpghoti/biscuit/commands/base/ClientCommand.java b/src/main/java/com/fpghoti/biscuit/commands/base/ClientCommand.java index 4967e20..a68f7f6 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/base/ClientCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/base/ClientCommand.java @@ -4,6 +4,7 @@ import com.fpghoti.biscuit.commands.BaseCommand; import com.fpghoti.biscuit.commands.CommandType; import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public abstract class ClientCommand extends BaseCommand{ @@ -11,7 +12,7 @@ public abstract class ClientCommand extends BaseCommand{ return true; } - public abstract void execute(String[] args, MessageReceivedEvent event); + public abstract void execute(String[] args, GuildMessageReceivedEvent event); public CommandType getType() { return CommandType.CLIENT; diff --git a/src/main/java/com/fpghoti/biscuit/commands/base/CustomCommand.java b/src/main/java/com/fpghoti/biscuit/commands/base/CustomCommand.java index 1e52599..0c5eef3 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/base/CustomCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/base/CustomCommand.java @@ -4,11 +4,11 @@ import com.fpghoti.biscuit.biscuit.Biscuit; import com.fpghoti.biscuit.commands.BaseCommand; import com.fpghoti.biscuit.commands.CommandType; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public class CustomCommand extends BaseCommand { - public static String fixPlaceholders(MessageReceivedEvent event, String msg) { + public static String fixPlaceholders(GuildMessageReceivedEvent event, String msg) { msg = msg.replace("", event.getAuthor().getAsMention()); return msg; } diff --git a/src/main/java/com/fpghoti/biscuit/commands/base/MusicClientCommand.java b/src/main/java/com/fpghoti/biscuit/commands/base/MusicClientCommand.java index 4499d46..3d9da57 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/base/MusicClientCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/base/MusicClientCommand.java @@ -1,9 +1,9 @@ package com.fpghoti.biscuit.commands.base; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public abstract class MusicClientCommand extends ClientCommand{ - public abstract void execute(String[] args, MessageReceivedEvent event); + public abstract void execute(String[] args, GuildMessageReceivedEvent event); } diff --git a/src/main/java/com/fpghoti/biscuit/commands/client/AddCommand.java b/src/main/java/com/fpghoti/biscuit/commands/client/AddCommand.java index 2fd0afb..115a74c 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/client/AddCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/client/AddCommand.java @@ -5,7 +5,7 @@ import com.fpghoti.biscuit.biscuit.Biscuit; import com.fpghoti.biscuit.commands.base.ClientCommand; import com.fpghoti.biscuit.util.Util; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public class AddCommand extends ClientCommand{ @@ -19,7 +19,7 @@ public class AddCommand extends ClientCommand{ } @Override - public void execute(String[] args, MessageReceivedEvent event) { + public void execute(String[] args, GuildMessageReceivedEvent event) { Biscuit b = Biscuit.getBiscuit(event.getGuild()); b.log(event.getAuthor().getName() + " issued a command: -add"); if(args[0] != null && Util.isDeciDigit(args[0]) && args[1] != null && Util.isDeciDigit(args[1])) { @@ -30,7 +30,7 @@ public class AddCommand extends ClientCommand{ if(end.equals(".0")) { sum = sum.replace(".0",""); } - event.getTextChannel().sendMessage(args[0] + " + " + args[1] + " is **" + sum + "**.").queue(); + event.getChannel().sendMessage(args[0] + " + " + args[1] + " is **" + sum + "**.").queue(); } } diff --git a/src/main/java/com/fpghoti/biscuit/commands/client/ChanIDCommand.java b/src/main/java/com/fpghoti/biscuit/commands/client/ChanIDCommand.java index 8fab3c0..a2896e5 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/client/ChanIDCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/client/ChanIDCommand.java @@ -4,7 +4,7 @@ import com.fpghoti.biscuit.Main; import com.fpghoti.biscuit.biscuit.Biscuit; import com.fpghoti.biscuit.commands.base.ClientCommand; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public class ChanIDCommand extends ClientCommand{ @@ -18,11 +18,11 @@ public class ChanIDCommand extends ClientCommand{ } @Override - public void execute(String[] args, MessageReceivedEvent event) { + public void execute(String[] args, GuildMessageReceivedEvent event) { Biscuit b = Biscuit.getBiscuit(event.getGuild()); b.log(event.getAuthor().getName() + " issued a command: -chanid"); - String id = event.getTextChannel().getId(); - event.getTextChannel().sendMessage(id).queue(); + String id = event.getChannel().getId(); + event.getChannel().sendMessage(id).queue(); } } diff --git a/src/main/java/com/fpghoti/biscuit/commands/client/DivideCommand.java b/src/main/java/com/fpghoti/biscuit/commands/client/DivideCommand.java index 46d2bab..bf05d25 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/client/DivideCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/client/DivideCommand.java @@ -5,7 +5,7 @@ import com.fpghoti.biscuit.biscuit.Biscuit; import com.fpghoti.biscuit.commands.base.ClientCommand; import com.fpghoti.biscuit.util.Util; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public class DivideCommand extends ClientCommand{ @@ -20,7 +20,7 @@ public class DivideCommand extends ClientCommand{ } @Override - public void execute(String[] args, MessageReceivedEvent event) { + public void execute(String[] args, GuildMessageReceivedEvent event) { Biscuit b = Biscuit.getBiscuit(event.getGuild()); b.log(event.getAuthor().getName() + " issued a command: -divide"); if(args[0] != null && Util.isDeciDigit(args[0]) && args[1] != null && Util.isDeciDigit(args[1])) { @@ -31,7 +31,7 @@ public class DivideCommand extends ClientCommand{ if(end.equals(".0")) { divide = divide.replace(".0",""); } - event.getTextChannel().sendMessage(args[0] + " / " + args[1] + " is **" + divide + "**.").queue(); + event.getChannel().sendMessage(args[0] + " / " + args[1] + " is **" + divide + "**.").queue(); } } diff --git a/src/main/java/com/fpghoti/biscuit/commands/client/ForceSkipCommand.java b/src/main/java/com/fpghoti/biscuit/commands/client/ForceSkipCommand.java index 69e8c06..6be530d 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/client/ForceSkipCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/client/ForceSkipCommand.java @@ -5,7 +5,8 @@ import com.fpghoti.biscuit.biscuit.Biscuit; import com.fpghoti.biscuit.commands.base.MusicClientCommand; import com.fpghoti.biscuit.util.PermUtil; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.entities.MessageEmbed; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public class ForceSkipCommand extends MusicClientCommand{ @@ -19,13 +20,14 @@ public class ForceSkipCommand extends MusicClientCommand{ } @Override - public void execute(String[] args, MessageReceivedEvent event) { + public void execute(String[] args, GuildMessageReceivedEvent event) { Biscuit b = Biscuit.getBiscuit(event.getGuild()); b.log(event.getAuthor().getName() + " issued a command: -forceskip"); if(PermUtil.isMod(event.getMember())) { event.getChannel().sendMessage("Force skipping current song.").queue(); - if(b.getAudioScheduler().getNextMessage() != null ) { - event.getChannel().sendMessage(b.getAudioScheduler().getNextMessage()).queue(); + if(b.getAudioScheduler().getQueue().getNext() != null ) { + MessageEmbed next = b.getAudioScheduler().getQueue().getNext().getEmbedMessage("Now Playing:"); + event.getChannel().sendMessage(next).queue(); } b.getAudioScheduler().skip(); } diff --git a/src/main/java/com/fpghoti/biscuit/commands/client/GetConfigCommand.java b/src/main/java/com/fpghoti/biscuit/commands/client/GetConfigCommand.java index dbbdbf2..8fefa22 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/client/GetConfigCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/client/GetConfigCommand.java @@ -10,7 +10,7 @@ import com.fpghoti.biscuit.logging.BColor; import com.fpghoti.biscuit.util.PermUtil; import net.dv8tion.jda.api.entities.Message; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public class GetConfigCommand extends ClientCommand{ @@ -24,14 +24,14 @@ public class GetConfigCommand extends ClientCommand{ } @Override - public void execute(String[] args, MessageReceivedEvent event) { + public void execute(String[] args, GuildMessageReceivedEvent event) { Biscuit b = Biscuit.getBiscuit(event.getGuild()); b.log(event.getAuthor().getName() + " issued a command: -getconfig"); if(PermUtil.isAdmin(event.getMember())) { - event.getTextChannel().sendFile(b.getConfig().getFile(), "config-" + b.getProperties().getGuildCode() + ".properties").queue(); + event.getChannel().sendFile(b.getConfig().getFile(), "config-" + b.getProperties().getGuildCode() + ".properties").queue(); }else { b.log(BColor.MAGENTA_BOLD + event.getAuthor().getName() + " lacks permission to view the config!"); - event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + " You do not have " + event.getChannel().sendMessage(event.getAuthor().getAsMention() + " You do not have " + "permission to view the config.").queue(new Consumer() { @Override diff --git a/src/main/java/com/fpghoti/biscuit/commands/client/GuildIDCommand.java b/src/main/java/com/fpghoti/biscuit/commands/client/GuildIDCommand.java index 559dcea..082860f 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/client/GuildIDCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/client/GuildIDCommand.java @@ -5,7 +5,7 @@ import com.fpghoti.biscuit.biscuit.Biscuit; import com.fpghoti.biscuit.commands.base.ClientCommand; import com.fpghoti.biscuit.util.PermUtil; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public class GuildIDCommand extends ClientCommand{ @@ -20,11 +20,11 @@ public class GuildIDCommand extends ClientCommand{ } @Override - public void execute(String[] args, MessageReceivedEvent event) { + public void execute(String[] args, GuildMessageReceivedEvent event) { Biscuit b = Biscuit.getBiscuit(event.getGuild()); b.log(event.getAuthor().getName() + " issued a command: -guildid"); if(PermUtil.isMod(event.getMember())) { - event.getTextChannel().sendMessage(event.getGuild().getId()).queue(); + event.getChannel().sendMessage(event.getGuild().getId()).queue(); } } diff --git a/src/main/java/com/fpghoti/biscuit/commands/client/HelpCommand.java b/src/main/java/com/fpghoti/biscuit/commands/client/HelpCommand.java index d064a26..af44956 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/client/HelpCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/client/HelpCommand.java @@ -12,7 +12,7 @@ import com.fpghoti.biscuit.commands.base.CustomCommand; import com.fpghoti.biscuit.commands.base.MusicClientCommand; import com.fpghoti.biscuit.util.Util; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public class HelpCommand extends ClientCommand { @@ -26,7 +26,7 @@ public class HelpCommand extends ClientCommand { } @Override - public void execute(String[] args, MessageReceivedEvent event) { + public void execute(String[] args, GuildMessageReceivedEvent event) { Biscuit biscuit = Biscuit.getBiscuit(event.getGuild()); @@ -35,7 +35,7 @@ public class HelpCommand extends ClientCommand { if(Util.isDigit(args[0])) { pg = Integer.parseInt(args[0]); }else { - event.getTextChannel().sendMessage("Usage: ``" + usage + "``").queue(); + event.getChannel().sendMessage("Usage: ``" + usage + "``").queue(); } } List commands = new ArrayList(); @@ -72,8 +72,8 @@ public class HelpCommand extends ClientCommand { pg = pageCount; } - event.getTextChannel().sendMessage("**Use " + Main.getMainBiscuit().getProperties().getCommandSignifier() + "help [Page #] to navigate the different pages.**").queue(); - event.getTextChannel().sendMessage("[" + Integer.toString(pg) + "/" + Integer.toString(pageCount) + "] **Bot Commands:**").queue(); + event.getChannel().sendMessage("**Use " + Main.getMainBiscuit().getProperties().getCommandSignifier() + "help [Page #] to navigate the different pages.**").queue(); + event.getChannel().sendMessage("[" + Integer.toString(pg) + "/" + Integer.toString(pageCount) + "] **Bot Commands:**").queue(); String msg = ""; for (int i = 0; i < 8; i++) { int index = (pg - 1) * 8 + i; @@ -88,7 +88,7 @@ public class HelpCommand extends ClientCommand { msg = msg + line; } } - event.getTextChannel().sendMessage(msg).queue(); + event.getChannel().sendMessage(msg).queue(); } diff --git a/src/main/java/com/fpghoti/biscuit/commands/client/LoopMusicCommand.java b/src/main/java/com/fpghoti/biscuit/commands/client/LoopMusicCommand.java index b0cb277..92cdb9a 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/client/LoopMusicCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/client/LoopMusicCommand.java @@ -5,7 +5,7 @@ import com.fpghoti.biscuit.biscuit.Biscuit; import com.fpghoti.biscuit.commands.base.MusicClientCommand; import com.fpghoti.biscuit.util.PermUtil; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public class LoopMusicCommand extends MusicClientCommand{ @@ -19,7 +19,7 @@ public class LoopMusicCommand extends MusicClientCommand{ } @Override - public void execute(String[] args, MessageReceivedEvent event) { + public void execute(String[] args, GuildMessageReceivedEvent event) { Biscuit b = Biscuit.getBiscuit(event.getGuild()); b.log(event.getAuthor().getName() + " issued a command: -loopmusic"); if(PermUtil.isMod(event.getMember())) { diff --git a/src/main/java/com/fpghoti/biscuit/commands/client/MakeInviteCommand.java b/src/main/java/com/fpghoti/biscuit/commands/client/MakeInviteCommand.java index 61c07f8..6c037a8 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/client/MakeInviteCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/client/MakeInviteCommand.java @@ -8,7 +8,7 @@ import com.fpghoti.biscuit.util.Util; import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.TextChannel; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public class MakeInviteCommand extends ClientCommand{ @@ -22,7 +22,7 @@ public class MakeInviteCommand extends ClientCommand{ } @Override - public void execute(String[] args, MessageReceivedEvent event) { + public void execute(String[] args, GuildMessageReceivedEvent event) { double doubAge = 0; if(args.length == 2 && Util.isDeciDigit(args[1])) { doubAge = Double.parseDouble(args[1]) * 3600; diff --git a/src/main/java/com/fpghoti/biscuit/commands/client/MultiplyCommand.java b/src/main/java/com/fpghoti/biscuit/commands/client/MultiplyCommand.java index 3fd1462..04e87af 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/client/MultiplyCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/client/MultiplyCommand.java @@ -5,7 +5,7 @@ import com.fpghoti.biscuit.biscuit.Biscuit; import com.fpghoti.biscuit.commands.base.ClientCommand; import com.fpghoti.biscuit.util.Util; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public class MultiplyCommand extends ClientCommand{ @@ -20,7 +20,7 @@ public class MultiplyCommand extends ClientCommand{ } @Override - public void execute(String[] args, MessageReceivedEvent event) { + public void execute(String[] args, GuildMessageReceivedEvent event) { Biscuit b = Biscuit.getBiscuit(event.getGuild()); b.log(event.getAuthor().getName() + " issued a command: -multiply"); if(args[0] != null && Util.isDeciDigit(args[0]) && args[1] != null && Util.isDeciDigit(args[1])) { @@ -31,7 +31,7 @@ public class MultiplyCommand extends ClientCommand{ if(end.equals(".0")) { prod = prod.replace(".0",""); } - event.getTextChannel().sendMessage(args[0] + " x " + args[1] + " is **" + prod + "**.").queue(); + event.getChannel().sendMessage(args[0] + " x " + args[1] + " is **" + prod + "**.").queue(); } } diff --git a/src/main/java/com/fpghoti/biscuit/commands/client/NotSpammerCommand.java b/src/main/java/com/fpghoti/biscuit/commands/client/NotSpammerCommand.java index 9e123b3..2d9a1e6 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/client/NotSpammerCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/client/NotSpammerCommand.java @@ -7,7 +7,7 @@ import com.fpghoti.biscuit.util.PermUtil; import net.dv8tion.jda.api.entities.Member; import net.dv8tion.jda.api.entities.User; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public class NotSpammerCommand extends ClientCommand{ @@ -21,7 +21,7 @@ public class NotSpammerCommand extends ClientCommand{ } @Override - public void execute(String[] args, MessageReceivedEvent event) { + public void execute(String[] args, GuildMessageReceivedEvent event) { Biscuit b = Biscuit.getBiscuit(event.getGuild()); b.log(event.getAuthor().getName() + " issued a command: -notspammer " + args[0]); for(Member m : event.getMessage().getMentionedMembers()){ @@ -29,7 +29,7 @@ public class NotSpammerCommand extends ClientCommand{ String s = u.getAsMention(); if(event.getChannel().getName().equals("public-spam-test") || (PermUtil.isMod(event.getMember()))) { b.getMessageStore().removeSpammer(u); - event.getTextChannel().sendMessage(s+ " is no longer flagged as spam.").queue(); + event.getChannel().sendMessage(s+ " is no longer flagged as spam.").queue(); } } } diff --git a/src/main/java/com/fpghoti/biscuit/commands/client/NowPlayingCommand.java b/src/main/java/com/fpghoti/biscuit/commands/client/NowPlayingCommand.java index 87540fc..3b768a8 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/client/NowPlayingCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/client/NowPlayingCommand.java @@ -3,9 +3,9 @@ package com.fpghoti.biscuit.commands.client; import com.fpghoti.biscuit.Main; import com.fpghoti.biscuit.biscuit.Biscuit; import com.fpghoti.biscuit.commands.base.MusicClientCommand; -import com.sedmelluq.discord.lavaplayer.track.AudioTrack; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.entities.MessageEmbed; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public class NowPlayingCommand extends MusicClientCommand{ @@ -19,12 +19,12 @@ public class NowPlayingCommand extends MusicClientCommand{ } @Override - public void execute(String[] args, MessageReceivedEvent event) { + public void execute(String[] args, GuildMessageReceivedEvent event) { Biscuit b = Biscuit.getBiscuit(event.getGuild()); b.log(event.getAuthor().getName() + " issued a command: -nowplaying"); - if(b.getAudioPlayer().getPlayingTrack() != null) { - AudioTrack track = b.getAudioPlayer().getPlayingTrack(); - event.getChannel().sendMessage(b.getAudioScheduler().getMessage(track, true)).queue(); + if(b.getAudioScheduler().getQueue().getLastTrack() != null ) { + MessageEmbed next = b.getAudioScheduler().getQueue().getLastTrack().getEmbedMessage("Now Playing:", true); + event.getChannel().sendMessage(next).queue(); }else { event.getChannel().sendMessage("No song is currently playing.").queue(); } diff --git a/src/main/java/com/fpghoti/biscuit/commands/client/PauseCommand.java b/src/main/java/com/fpghoti/biscuit/commands/client/PauseCommand.java index 13d99cc..0e73dd3 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/client/PauseCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/client/PauseCommand.java @@ -5,7 +5,7 @@ import com.fpghoti.biscuit.biscuit.Biscuit; import com.fpghoti.biscuit.commands.base.MusicClientCommand; import com.fpghoti.biscuit.util.PermUtil; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public class PauseCommand extends MusicClientCommand{ @@ -19,7 +19,7 @@ public class PauseCommand extends MusicClientCommand{ } @Override - public void execute(String[] args, MessageReceivedEvent event) { + public void execute(String[] args, GuildMessageReceivedEvent event) { Biscuit b = Biscuit.getBiscuit(event.getGuild()); b.log(event.getAuthor().getName() + " issued a command: -pause"); if(PermUtil.isMod(event.getMember())) { diff --git a/src/main/java/com/fpghoti/biscuit/commands/client/PingCommand.java b/src/main/java/com/fpghoti/biscuit/commands/client/PingCommand.java index e3e6e2c..0c008e9 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/client/PingCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/client/PingCommand.java @@ -4,7 +4,7 @@ import com.fpghoti.biscuit.Main; import com.fpghoti.biscuit.biscuit.Biscuit; import com.fpghoti.biscuit.commands.base.ClientCommand; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public class PingCommand extends ClientCommand{ @@ -18,10 +18,10 @@ public class PingCommand extends ClientCommand{ } @Override - public void execute(String[] args, MessageReceivedEvent event) { + public void execute(String[] args, GuildMessageReceivedEvent event) { Biscuit b = Biscuit.getBiscuit(event.getGuild()); b.log(event.getAuthor().getName() + " issued a command: -ping"); - event.getTextChannel().sendMessage("Pong!").queue(); + event.getChannel().sendMessage("Pong!").queue(); } } diff --git a/src/main/java/com/fpghoti/biscuit/commands/client/PlayCommand.java b/src/main/java/com/fpghoti/biscuit/commands/client/PlayCommand.java index 1c07662..2dad924 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/client/PlayCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/client/PlayCommand.java @@ -10,7 +10,7 @@ import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager; import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.TextChannel; import net.dv8tion.jda.api.entities.VoiceChannel; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; import net.dv8tion.jda.api.managers.AudioManager; public class PlayCommand extends MusicClientCommand{ @@ -25,10 +25,10 @@ public class PlayCommand extends MusicClientCommand{ } @Override - public void execute(String[] args, MessageReceivedEvent event) { + public void execute(String[] args, GuildMessageReceivedEvent event) { Guild guild = event.getGuild(); Biscuit b = Biscuit.getBiscuit(guild); - TextChannel tchannel = event.getTextChannel(); + TextChannel tchannel = event.getChannel(); String searchPhrase = args[0]; if(args.length > 1) { @@ -75,7 +75,7 @@ public class PlayCommand extends MusicClientCommand{ AudioPlayerManager playerManager = Main.getPlayerManager(); String vidid = getID(event.getMessage().getContentRaw().split(" ")[1]); - playerManager.loadItemOrdered(guild, vidid, new AudioResultHandler(b,event.getAuthor().getId(), tchannel, false, searchPhrase)); + playerManager.loadItemOrdered(guild, vidid, new AudioResultHandler(event.getAuthor().getId(), tchannel, false, searchPhrase, false, false)); } private String getID(String url) { diff --git a/src/main/java/com/fpghoti/biscuit/commands/client/PlayFirstCommand.java b/src/main/java/com/fpghoti/biscuit/commands/client/PlayFirstCommand.java index 9508ca1..20eab6e 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/client/PlayFirstCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/client/PlayFirstCommand.java @@ -11,7 +11,7 @@ import com.sedmelluq.discord.lavaplayer.player.AudioPlayerManager; import net.dv8tion.jda.api.entities.Guild; import net.dv8tion.jda.api.entities.TextChannel; import net.dv8tion.jda.api.entities.VoiceChannel; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; import net.dv8tion.jda.api.managers.AudioManager; public class PlayFirstCommand extends MusicClientCommand{ @@ -26,10 +26,10 @@ public class PlayFirstCommand extends MusicClientCommand{ } @Override - public void execute(String[] args, MessageReceivedEvent event) { + public void execute(String[] args, GuildMessageReceivedEvent event) { Guild guild = event.getGuild(); Biscuit b = Biscuit.getBiscuit(guild); - TextChannel tchannel = event.getTextChannel(); + TextChannel tchannel = event.getChannel(); String searchPhrase = args[0]; if(args.length > 1) { @@ -82,7 +82,7 @@ public class PlayFirstCommand extends MusicClientCommand{ AudioPlayerManager playerManager = Main.getPlayerManager(); String vidid = getID(event.getMessage().getContentRaw().split(" ")[1]); - playerManager.loadItemOrdered(guild, vidid, new AudioResultHandler(b,event.getAuthor().getId(), tchannel, false, searchPhrase, true)); + playerManager.loadItemOrdered(guild, vidid, new AudioResultHandler(event.getAuthor().getId(), tchannel, false, searchPhrase, true, false)); } private String getID(String url) { diff --git a/src/main/java/com/fpghoti/biscuit/commands/client/PowerCommand.java b/src/main/java/com/fpghoti/biscuit/commands/client/PowerCommand.java index c153be3..167de84 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/client/PowerCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/client/PowerCommand.java @@ -5,7 +5,7 @@ import com.fpghoti.biscuit.biscuit.Biscuit; import com.fpghoti.biscuit.commands.base.ClientCommand; import com.fpghoti.biscuit.util.Util; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public class PowerCommand extends ClientCommand{ @@ -20,7 +20,7 @@ public class PowerCommand extends ClientCommand{ } @Override - public void execute(String[] args, MessageReceivedEvent event) { + public void execute(String[] args, GuildMessageReceivedEvent event) { Biscuit b = Biscuit.getBiscuit(event.getGuild()); b.log(event.getAuthor().getName() + " issued a command: -power"); if(args[0] != null && Util.isDeciDigit(args[0]) && args[1] != null && Util.isDeciDigit(args[1])) { @@ -31,7 +31,7 @@ public class PowerCommand extends ClientCommand{ if(end.equals(".0")) { pow = pow.replace(".0",""); } - event.getTextChannel().sendMessage(args[0] + "^" + args[1] + " is **" + pow + "**.").queue(); + event.getChannel().sendMessage(args[0] + "^" + args[1] + " is **" + pow + "**.").queue(); } } diff --git a/src/main/java/com/fpghoti/biscuit/commands/client/QueueCommand.java b/src/main/java/com/fpghoti/biscuit/commands/client/QueueCommand.java index 07fb349..e973025 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/client/QueueCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/client/QueueCommand.java @@ -9,7 +9,7 @@ import com.fpghoti.biscuit.util.Util; import com.sedmelluq.discord.lavaplayer.track.AudioTrack; import net.dv8tion.jda.api.entities.Member; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public class QueueCommand extends MusicClientCommand{ @@ -23,7 +23,7 @@ public class QueueCommand extends MusicClientCommand{ } @Override - public void execute(String[] args, MessageReceivedEvent event) { + public void execute(String[] args, GuildMessageReceivedEvent event) { Biscuit biscuit = Biscuit.getBiscuit(event.getGuild()); biscuit.log(event.getAuthor().getName() + " issued a command: -queue"); @@ -32,7 +32,7 @@ public class QueueCommand extends MusicClientCommand{ if(Util.isDigit(args[0])) { pg = Integer.parseInt(args[0]); }else { - event.getTextChannel().sendMessage("Usage: ``" + usage + "``").queue(); + event.getChannel().sendMessage("Usage: ``" + usage + "``").queue(); } } @@ -45,15 +45,15 @@ public class QueueCommand extends MusicClientCommand{ if(queue.size() == 0) { if(biscuit.getAudioPlayer().getPlayingTrack() == null) { - event.getTextChannel().sendMessage("There is currently no song playing.").queue(); + event.getChannel().sendMessage("There is currently no song playing.").queue(); }else { - event.getTextChannel().sendMessage("Nothing is queued to play after the current track.").queue(); + event.getChannel().sendMessage("Nothing is queued to play after the current track.").queue(); } return; } - event.getTextChannel().sendMessage("**Use " + Main.getMainBiscuit().getProperties().getCommandSignifier() + "queue [Page #] to navigate the different pages.**").queue(); - event.getTextChannel().sendMessage("[" + Integer.toString(pg) + "/" + Integer.toString(pageCount) + "] ** Upcoming Music Tracks:**").queue(); + event.getChannel().sendMessage("**Use " + Main.getMainBiscuit().getProperties().getCommandSignifier() + "queue [Page #] to navigate the different pages.**").queue(); + event.getChannel().sendMessage("[" + Integer.toString(pg) + "/" + Integer.toString(pageCount) + "] ** Upcoming Music Tracks:**").queue(); String msg = ""; for (int i = 0; i < 8; i++) { int index = (pg - 1) * 8 + i; @@ -75,7 +75,7 @@ public class QueueCommand extends MusicClientCommand{ msg = msg + line; } } - event.getTextChannel().sendMessage(msg).queue(); + event.getChannel().sendMessage(msg).queue(); } diff --git a/src/main/java/com/fpghoti/biscuit/commands/client/RecentSpammersCommand.java b/src/main/java/com/fpghoti/biscuit/commands/client/RecentSpammersCommand.java index 7bd90f7..0bbbbf3 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/client/RecentSpammersCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/client/RecentSpammersCommand.java @@ -4,7 +4,7 @@ import com.fpghoti.biscuit.Main; import com.fpghoti.biscuit.biscuit.Biscuit; import com.fpghoti.biscuit.commands.base.ClientCommand; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public class RecentSpammersCommand extends ClientCommand{ @@ -18,11 +18,11 @@ public class RecentSpammersCommand extends ClientCommand{ } @Override - public void execute(String[] args, MessageReceivedEvent event) { + public void execute(String[] args, GuildMessageReceivedEvent event) { Biscuit b = Biscuit.getBiscuit(event.getGuild()); b.log(event.getAuthor().getName() + " issued a command: -recentspammers"); String msg = b.getMessageStore().getSpammerList(); - event.getTextChannel().sendMessage(msg).queue(); + event.getChannel().sendMessage(msg).queue(); } diff --git a/src/main/java/com/fpghoti/biscuit/commands/client/SaveConfigCommand.java b/src/main/java/com/fpghoti/biscuit/commands/client/SaveConfigCommand.java index b370efe..93a26b4 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/client/SaveConfigCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/client/SaveConfigCommand.java @@ -12,7 +12,7 @@ import com.fpghoti.biscuit.util.PermUtil; import net.dv8tion.jda.api.entities.Message; import net.dv8tion.jda.api.entities.Message.Attachment; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public class SaveConfigCommand extends ClientCommand{ @@ -26,7 +26,7 @@ public class SaveConfigCommand extends ClientCommand{ } @Override - public void execute(String[] args, MessageReceivedEvent event) { + public void execute(String[] args, GuildMessageReceivedEvent event) { Biscuit b = Biscuit.getBiscuit(event.getGuild()); b.log(event.getAuthor().getName() + " issued a command: -saveconfig"); List attch = event.getMessage().getAttachments(); @@ -34,12 +34,12 @@ public class SaveConfigCommand extends ClientCommand{ if(!attch.isEmpty()) { if(attch.size() == 1) { for(Attachment a : attch) { - b.getConfig().replaceConfig(a, event.getTextChannel()); + b.getConfig().replaceConfig(a, event.getChannel()); b.remove(); b = Biscuit.loadGuild(event.getGuild()); } }else { - event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + " Too many attachments added! " + event.getChannel().sendMessage(event.getAuthor().getAsMention() + " Too many attachments added! " + "Please only include the config file you want to save.").queue(new Consumer() { @Override @@ -49,7 +49,7 @@ public class SaveConfigCommand extends ClientCommand{ }); } }else { - event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + " You need to send " + event.getChannel().sendMessage(event.getAuthor().getAsMention() + " You need to send " + "a file in order to save the config.").queue(new Consumer() { @Override @@ -60,7 +60,7 @@ public class SaveConfigCommand extends ClientCommand{ } }else { b.log(BColor.MAGENTA_BOLD + event.getAuthor().getName() + " lacks permission to save the config!"); - event.getTextChannel().sendMessage(event.getAuthor().getAsMention() + " You do not have " + event.getChannel().sendMessage(event.getAuthor().getAsMention() + " You do not have " + "permission to save the config.").queue(new Consumer() { @Override diff --git a/src/main/java/com/fpghoti/biscuit/commands/client/SkipCommand.java b/src/main/java/com/fpghoti/biscuit/commands/client/SkipCommand.java index 4918de8..04705f2 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/client/SkipCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/client/SkipCommand.java @@ -4,7 +4,8 @@ import com.fpghoti.biscuit.Main; import com.fpghoti.biscuit.biscuit.Biscuit; import com.fpghoti.biscuit.commands.base.MusicClientCommand; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.entities.MessageEmbed; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public class SkipCommand extends MusicClientCommand{ @@ -18,7 +19,10 @@ public class SkipCommand extends MusicClientCommand{ } @Override - public void execute(String[] args, MessageReceivedEvent event) { + public void execute(String[] args, GuildMessageReceivedEvent event) { + + //TODO Redo vote skipping. It does not function correctly. + Biscuit b = Biscuit.getBiscuit(event.getGuild()); b.log(event.getAuthor().getName() + " issued a command: -skip"); @@ -26,7 +30,7 @@ public class SkipCommand extends MusicClientCommand{ event.getChannel().sendMessage("There is not a song playing for you to skip!").queue(); return; } - + if(!event.getGuild().getAudioManager().getConnectedChannel().getMembers().contains(event.getMember())) { event.getChannel().sendMessage("You need to be in the same voice channel in order to skip!").queue(); return; @@ -36,8 +40,9 @@ public class SkipCommand extends MusicClientCommand{ event.getChannel().sendMessage("Skip vote status: **[" + ( b.getAudioScheduler().getVotes() + 1) + "/" + (event.getGuild().getAudioManager().getConnectedChannel().getMembers().size() - 1) + "]**" + "\nSkipping current track.").queue(); - if(b.getAudioScheduler().getNextMessage() != null ) { - event.getChannel().sendMessage(b.getAudioScheduler().getNextMessage()).queue(); + if(b.getAudioScheduler().getQueue().getNext() != null ) { + MessageEmbed next = b.getAudioScheduler().getQueue().getNext().getEmbedMessage("Now Playing:"); + event.getChannel().sendMessage(next).queue(); } b.getAudioScheduler().skip(); return; @@ -54,8 +59,9 @@ public class SkipCommand extends MusicClientCommand{ event.getChannel().sendMessage("Skip vote status: **[" + b.getAudioScheduler().getVotes() + "/" + event.getGuild().getAudioManager().getConnectedChannel().getMembers().size() + "]**" + "\nSkipping current track.").queue(); - if(b.getAudioScheduler().getNextMessage() != null ) { - event.getChannel().sendMessage(b.getAudioScheduler().getNextMessage()).queue(); + if(b.getAudioScheduler().getQueue().getNext() != null ) { + MessageEmbed next = b.getAudioScheduler().getQueue().getNext().getEmbedMessage("Now Playing:"); + event.getChannel().sendMessage(next).queue(); } b.getAudioScheduler().skip(); } diff --git a/src/main/java/com/fpghoti/biscuit/commands/client/SoftMuteCommand.java b/src/main/java/com/fpghoti/biscuit/commands/client/SoftMuteCommand.java index d7c7c62..ccd7b04 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/client/SoftMuteCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/client/SoftMuteCommand.java @@ -11,7 +11,7 @@ import com.fpghoti.biscuit.util.PermUtil; import net.dv8tion.jda.api.entities.Member; import net.dv8tion.jda.api.entities.Message; import net.dv8tion.jda.api.entities.User; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public class SoftMuteCommand extends ClientCommand{ @@ -25,14 +25,14 @@ public class SoftMuteCommand extends ClientCommand{ } @Override - public void execute(String[] args, MessageReceivedEvent event) { + public void execute(String[] args, GuildMessageReceivedEvent event) { Biscuit b = Biscuit.getBiscuit(event.getGuild()); b.log(event.getAuthor().getName() + " issued a command: -softmute " + args[0]); for(Member m : event.getMessage().getMentionedMembers()){ User u = m.getUser(); String s = u.getAsMention(); if(b.getMessageStore().isSoftmuted(u)) { - event.getTextChannel().sendMessage(s+ " is already softmuted.").queue(new Consumer() + event.getChannel().sendMessage(s+ " is already softmuted.").queue(new Consumer() { @Override public void accept(Message msg){ @@ -44,7 +44,7 @@ public class SoftMuteCommand extends ClientCommand{ if(event.getChannel().getName().equals("public-softmute-test") || (PermUtil.isMod(event.getMember()))) { b.getMessageStore().addSoftmuted(u); u.openPrivateChannel().queue(); - event.getTextChannel().sendMessage(s+ " is now soft-muted. They will now be only able to send one message every two minutes.").queue(); + event.getChannel().sendMessage(s+ " is now soft-muted. They will now be only able to send one message every two minutes.").queue(); } } } diff --git a/src/main/java/com/fpghoti/biscuit/commands/client/SquareRootCommand.java b/src/main/java/com/fpghoti/biscuit/commands/client/SquareRootCommand.java index 9b6a7b6..8c193af 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/client/SquareRootCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/client/SquareRootCommand.java @@ -5,7 +5,7 @@ import com.fpghoti.biscuit.biscuit.Biscuit; import com.fpghoti.biscuit.commands.base.ClientCommand; import com.fpghoti.biscuit.util.Util; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public class SquareRootCommand extends ClientCommand{ @@ -20,7 +20,7 @@ public class SquareRootCommand extends ClientCommand{ } @Override - public void execute(String[] args, MessageReceivedEvent event) { + public void execute(String[] args, GuildMessageReceivedEvent event) { Biscuit b = Biscuit.getBiscuit(event.getGuild()); b.log(event.getAuthor().getName() + " issued a command: -squareroot"); if(args[0] != null && Util.isDeciDigit(args[0])) { @@ -30,7 +30,7 @@ public class SquareRootCommand extends ClientCommand{ if(end.equals(".0")) { root = root.replace(".0",""); } - event.getTextChannel().sendMessage("The sqaure root of " + args[0] + " is **" + root + "**.").queue(); + event.getChannel().sendMessage("The sqaure root of " + args[0] + " is **" + root + "**.").queue(); } } diff --git a/src/main/java/com/fpghoti/biscuit/commands/client/SubtractCommand.java b/src/main/java/com/fpghoti/biscuit/commands/client/SubtractCommand.java index a0f4ec6..aaa51d2 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/client/SubtractCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/client/SubtractCommand.java @@ -5,7 +5,7 @@ import com.fpghoti.biscuit.biscuit.Biscuit; import com.fpghoti.biscuit.commands.base.ClientCommand; import com.fpghoti.biscuit.util.Util; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public class SubtractCommand extends ClientCommand{ @@ -20,7 +20,7 @@ public class SubtractCommand extends ClientCommand{ } @Override - public void execute(String[] args, MessageReceivedEvent event) { + public void execute(String[] args, GuildMessageReceivedEvent event) { Biscuit b = Biscuit.getBiscuit(event.getGuild()); b.log(event.getAuthor().getName() + " issued a command: -subtract"); if(args[0] != null && Util.isDeciDigit(args[0]) && args[1] != null && Util.isDeciDigit(args[1])) { @@ -31,7 +31,7 @@ public class SubtractCommand extends ClientCommand{ if(end.equals(".0")) { sub = sub.replace(".0",""); } - event.getTextChannel().sendMessage(args[0] + " - " + args[1] + " is **" + sub + "**.").queue(); + event.getChannel().sendMessage(args[0] + " - " + args[1] + " is **" + sub + "**.").queue(); } } diff --git a/src/main/java/com/fpghoti/biscuit/commands/client/TogglePauseCommand.java b/src/main/java/com/fpghoti/biscuit/commands/client/TogglePauseCommand.java index 073c0d4..f8ef395 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/client/TogglePauseCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/client/TogglePauseCommand.java @@ -5,7 +5,7 @@ import com.fpghoti.biscuit.biscuit.Biscuit; import com.fpghoti.biscuit.commands.base.MusicClientCommand; import com.fpghoti.biscuit.util.PermUtil; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public class TogglePauseCommand extends MusicClientCommand{ @@ -20,7 +20,7 @@ public class TogglePauseCommand extends MusicClientCommand{ } @Override - public void execute(String[] args, MessageReceivedEvent event) { + public void execute(String[] args, GuildMessageReceivedEvent event) { Biscuit b = Biscuit.getBiscuit(event.getGuild()); b.log(event.getAuthor().getName() + " issued a command: -togglepause"); if(PermUtil.isMod(event.getMember())) { diff --git a/src/main/java/com/fpghoti/biscuit/commands/client/ToggleRoleCommand.java b/src/main/java/com/fpghoti/biscuit/commands/client/ToggleRoleCommand.java index 366c0f5..16027f4 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/client/ToggleRoleCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/client/ToggleRoleCommand.java @@ -7,7 +7,7 @@ import com.fpghoti.biscuit.util.PermUtil; import net.dv8tion.jda.api.entities.Emote; import net.dv8tion.jda.api.entities.Role; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public class ToggleRoleCommand extends ClientCommand{ @@ -22,7 +22,7 @@ public class ToggleRoleCommand extends ClientCommand{ } @Override - public void execute(String[] args, MessageReceivedEvent event) { + public void execute(String[] args, GuildMessageReceivedEvent event) { Biscuit b = Biscuit.getBiscuit(event.getGuild()); if(!event.getAuthor().isBot()) { b.log(event.getAuthor().getName() + " issued a command: -togglerole " + args[0]); @@ -37,7 +37,7 @@ public class ToggleRoleCommand extends ClientCommand{ } if(rolename.equals("")) { - event.getTextChannel().sendMessage("Sorry! This role either cannot be toggled or does not exist!").queue(); + event.getChannel().sendMessage("Sorry! This role either cannot be toggled or does not exist!").queue(); return; } diff --git a/src/main/java/com/fpghoti/biscuit/commands/client/UIDCommand.java b/src/main/java/com/fpghoti/biscuit/commands/client/UIDCommand.java index 640af4f..9844baf 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/client/UIDCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/client/UIDCommand.java @@ -7,7 +7,7 @@ import com.fpghoti.biscuit.util.PermUtil; import net.dv8tion.jda.api.entities.Member; import net.dv8tion.jda.api.entities.User; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public class UIDCommand extends ClientCommand{ @@ -21,13 +21,13 @@ public class UIDCommand extends ClientCommand{ } @Override - public void execute(String[] args, MessageReceivedEvent event) { + public void execute(String[] args, GuildMessageReceivedEvent event) { Biscuit b = Biscuit.getBiscuit(event.getGuild()); b.log(event.getAuthor().getName() + " issued a command: -uid " + args[0]); for(Member m : event.getMessage().getMentionedMembers()){ User u = m.getUser(); if(PermUtil.isMod(event.getMember())) { - event.getTextChannel().sendMessage(u.getId()).queue(); + event.getChannel().sendMessage(u.getId()).queue(); } } } diff --git a/src/main/java/com/fpghoti/biscuit/commands/client/UnSoftMuteCommand.java b/src/main/java/com/fpghoti/biscuit/commands/client/UnSoftMuteCommand.java index a9ba528..bc1e8dc 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/client/UnSoftMuteCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/client/UnSoftMuteCommand.java @@ -7,7 +7,7 @@ import com.fpghoti.biscuit.util.PermUtil; import net.dv8tion.jda.api.entities.Member; import net.dv8tion.jda.api.entities.User; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public class UnSoftMuteCommand extends ClientCommand{ @@ -21,7 +21,7 @@ public class UnSoftMuteCommand extends ClientCommand{ } @Override - public void execute(String[] args, MessageReceivedEvent event) { + public void execute(String[] args, GuildMessageReceivedEvent event) { Biscuit b = Biscuit.getBiscuit(event.getGuild()); b.log(event.getAuthor().getName() + " issued a command: -unsoftmute " + args[0]); for(Member m : event.getMessage().getMentionedMembers()){ @@ -29,7 +29,7 @@ public class UnSoftMuteCommand extends ClientCommand{ String s = u.getAsMention(); if(event.getChannel().getName().equals("public-softmute-test") || (PermUtil.isMod(event.getMember()))) { b.getMessageStore().removeSoftmuted(u); - event.getTextChannel().sendMessage(s+ " is no longer soft-muted.").queue(); + event.getChannel().sendMessage(s+ " is no longer soft-muted.").queue(); } } } diff --git a/src/main/java/com/fpghoti/biscuit/commands/client/UnpauseCommand.java b/src/main/java/com/fpghoti/biscuit/commands/client/UnpauseCommand.java index 07d56cf..8bf8a53 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/client/UnpauseCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/client/UnpauseCommand.java @@ -5,7 +5,7 @@ import com.fpghoti.biscuit.biscuit.Biscuit; import com.fpghoti.biscuit.commands.base.ClientCommand; import com.fpghoti.biscuit.util.PermUtil; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public class UnpauseCommand extends ClientCommand{ @@ -19,7 +19,7 @@ public class UnpauseCommand extends ClientCommand{ } @Override - public void execute(String[] args, MessageReceivedEvent event) { + public void execute(String[] args, GuildMessageReceivedEvent event) { Biscuit b = Biscuit.getBiscuit(event.getGuild()); b.log(event.getAuthor().getName() + " issued a command: -unpause"); if(PermUtil.isMod(event.getMember())) { diff --git a/src/main/java/com/fpghoti/biscuit/commands/client/WikiCommand.java b/src/main/java/com/fpghoti/biscuit/commands/client/WikiCommand.java index 947c66a..9489968 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/client/WikiCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/client/WikiCommand.java @@ -5,7 +5,7 @@ import com.fpghoti.biscuit.biscuit.Biscuit; import com.fpghoti.biscuit.commands.base.ClientCommand; import com.fpghoti.biscuit.util.PermUtil; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public class WikiCommand extends ClientCommand{ @@ -19,11 +19,11 @@ public class WikiCommand extends ClientCommand{ } @Override - public void execute(String[] args, MessageReceivedEvent event) { + public void execute(String[] args, GuildMessageReceivedEvent event) { Biscuit b = Biscuit.getBiscuit(event.getGuild()); b.log(event.getAuthor().getName() + " issued a command: -wiki"); if(PermUtil.isMod(event.getMember())) { - event.getTextChannel().sendMessage("https://git.fpghoti.com/thmsdy/Biscuit/wiki").queue(); + event.getChannel().sendMessage("https://git.fpghoti.com/thmsdy/Biscuit/wiki").queue(); } } diff --git a/src/main/java/com/fpghoti/biscuit/commands/client/WipeQueueCommand.java b/src/main/java/com/fpghoti/biscuit/commands/client/WipeQueueCommand.java index fb85105..b84b079 100644 --- a/src/main/java/com/fpghoti/biscuit/commands/client/WipeQueueCommand.java +++ b/src/main/java/com/fpghoti/biscuit/commands/client/WipeQueueCommand.java @@ -5,7 +5,7 @@ import com.fpghoti.biscuit.biscuit.Biscuit; import com.fpghoti.biscuit.commands.base.MusicClientCommand; import com.fpghoti.biscuit.util.PermUtil; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; public class WipeQueueCommand extends MusicClientCommand{ @@ -20,7 +20,7 @@ public class WipeQueueCommand extends MusicClientCommand{ } @Override - public void execute(String[] args, MessageReceivedEvent event) { + public void execute(String[] args, GuildMessageReceivedEvent event) { Biscuit b = Biscuit.getBiscuit(event.getGuild()); b.log(event.getAuthor().getName() + " issued a command: -wipequeue"); if(PermUtil.isMod(event.getMember())) { diff --git a/src/main/java/com/fpghoti/biscuit/listener/CommandListener.java b/src/main/java/com/fpghoti/biscuit/listener/CommandListener.java index ef37d2c..bd06046 100644 --- a/src/main/java/com/fpghoti/biscuit/listener/CommandListener.java +++ b/src/main/java/com/fpghoti/biscuit/listener/CommandListener.java @@ -7,9 +7,8 @@ import com.fpghoti.biscuit.commands.CommandManager; import com.fpghoti.biscuit.logging.BiscuitLog; import com.fpghoti.biscuit.util.PermUtil; -import net.dv8tion.jda.api.entities.ChannelType; import net.dv8tion.jda.api.entities.TextChannel; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; import net.dv8tion.jda.api.hooks.ListenerAdapter; public class CommandListener extends ListenerAdapter implements Runnable { @@ -23,15 +22,13 @@ public class CommandListener extends ListenerAdapter implements Runnable { } @Override - public void onMessageReceived(MessageReceivedEvent event){ - if (event.isFromType(ChannelType.TEXT)) { + public void onGuildMessageReceived(GuildMessageReceivedEvent event){ Biscuit b = Biscuit.getBiscuit(event.getGuild()); - if(PermUtil.isAdmin(event.getMember()) || !b.getProperties().restrictCmdChannels() || (b.getProperties().restrictCmdChannels() && isBotChannel(event.getTextChannel()))) { + if(PermUtil.isAdmin(event.getMember()) || !b.getProperties().restrictCmdChannels() || (b.getProperties().restrictCmdChannels() && isBotChannel(event.getChannel()))) { if(!event.getAuthor().isBot() && event.getMessage().getContentDisplay().startsWith(b.getProperties().getCommandSignifier()) && event.getMessage().getAuthor().getId() != event.getJDA().getSelfUser().getId()){ CommandManager.parse(event.getMessage().getContentRaw().toLowerCase(), event); } } - } } private boolean isBotChannel(TextChannel c) {