Bot will seach for another video if the selected video cannot be played

This commit is contained in:
Ghoti 2020-07-22 23:13:27 -05:00
parent 82a25dbe09
commit eb3a5d2990
40 changed files with 293 additions and 255 deletions

View File

@ -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;
private boolean playAfterQueue;
public AudioResultHandler(Biscuit biscuit, String uid, TextChannel channel, boolean search,
String searchPhrase, boolean first, boolean stop) {
this.biscuit = biscuit;
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();
}
@ -101,4 +70,6 @@ public class AudioResultHandler implements AudioLoadResultHandler {
channel.sendMessage("An error was encountered while attempting to load audio.").queue();
}
}

View File

@ -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) {
if(queue.isEmpty() && biscuit.getAudioPlayer().getPlayingTrack() == null) {
queue.addPreviousTrack(new QueuedTrack(biscuit, track, uid, channel));
biscuit.getAudioPlayer().playTrack(track);
}else {
queue.add(new QueuedTrack(biscuit, track, uid, channel));
}
queue(track, uid, channel, null);
}
public void queueFirst(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.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));
}
}
}
@ -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();
}

View File

@ -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<QueuedTrack> tracks;
@ -77,20 +80,33 @@ 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.
public boolean moveToPlace(int oldPlace, int newPlace) {
@ -114,6 +130,9 @@ public class AudioQueue {
}
public QueuedTrack getNext() {
if(isEmpty()) {
return null;
}
return tracks.get(0);
}

View File

@ -1,9 +1,14 @@
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 {
@ -12,12 +17,14 @@ public class QueuedTrack {
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() {
@ -40,4 +47,60 @@ public class QueuedTrack {
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=");
}
}

View File

@ -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<BaseCommand> commands = new ArrayList<BaseCommand>();
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<String> split = new ArrayList<String>();
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<String> 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);
}

View File

@ -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;

View File

@ -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("<user>", event.getAuthor().getAsMention());
return msg;
}

View File

@ -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);
}

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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();
}

View File

@ -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<Message>()
{
@Override

View File

@ -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();
}
}

View File

@ -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<BaseCommand> commands = new ArrayList<BaseCommand>();
@ -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();
}

View File

@ -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())) {

View File

@ -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;

View File

@ -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();
}
}

View File

@ -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();
}
}
}

View File

@ -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();
}

View File

@ -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())) {

View File

@ -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();
}
}

View File

@ -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) {

View File

@ -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) {

View File

@ -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();
}
}

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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<Attachment> 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<Message>()
{
@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<Message>()
{
@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<Message>()
{
@Override

View File

@ -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");
@ -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();
}

View File

@ -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<Message>()
event.getChannel().sendMessage(s+ " is already softmuted.").queue(new Consumer<Message>()
{
@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();
}
}
}

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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())) {

View File

@ -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;
}

View File

@ -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();
}
}
}

View File

@ -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();
}
}
}

View File

@ -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())) {

View File

@ -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();
}
}

View File

@ -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())) {

View File

@ -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) {