diff --git a/pom.xml b/pom.xml
index 265a10c..37a1f7a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -70,7 +70,7 @@
com.github.andrewlalis
TengwarTranslatorLibrary
- 1.3
+ 1.3.1
com.google.apis
diff --git a/src/main/java/handiebot/command/Commands.java b/src/main/java/handiebot/command/Commands.java
index 051fcea..d919925 100644
--- a/src/main/java/handiebot/command/Commands.java
+++ b/src/main/java/handiebot/command/Commands.java
@@ -7,6 +7,7 @@ import handiebot.command.commands.misc.TengwarCommand;
import handiebot.command.commands.music.*;
import handiebot.command.commands.support.HelpCommand;
import handiebot.command.commands.support.InfoCommand;
+import handiebot.command.commands.support.ReportCommand;
import handiebot.command.types.Command;
import handiebot.command.types.ContextCommand;
import handiebot.command.types.StaticCommand;
@@ -41,6 +42,7 @@ public class Commands {
//Other commands.
commands.add(new HelpCommand());
commands.add(new InfoCommand());
+ commands.add(new ReportCommand());
commands.add(new SetPrefixCommand());
commands.add(new QuitCommand());
commands.add(new BroadcastCommand());
diff --git a/src/main/java/handiebot/command/commands/misc/TengwarCommand.java b/src/main/java/handiebot/command/commands/misc/TengwarCommand.java
index 127b8a8..0fdffc0 100644
--- a/src/main/java/handiebot/command/commands/misc/TengwarCommand.java
+++ b/src/main/java/handiebot/command/commands/misc/TengwarCommand.java
@@ -6,6 +6,8 @@ import handiebot.utils.MessageUtils;
import net.agspace.TengwarImageGenerator;
import net.agspace.Translator;
+import java.awt.*;
+
import static handiebot.HandieBot.resourceBundle;
import static handiebot.utils.MessageUtils.sendFile;
import static handiebot.utils.MessageUtils.sendMessage;
@@ -35,7 +37,9 @@ public class TengwarCommand extends ContextCommand {
24f,
false,
false,
- System.getProperty("user.home")+"/.handiebot/tengwarTemp.png"),
+ System.getProperty("user.home")+"/.handiebot/tengwarTemp.png",
+ Color.white,
+ Color.black),
"Raw text: `" +result+'`',
context.getChannel());
} else if (context.getArgs()[0].equalsIgnoreCase("from")){
diff --git a/src/main/java/handiebot/command/commands/music/QueueCommand.java b/src/main/java/handiebot/command/commands/music/QueueCommand.java
index d535460..36cbd1d 100644
--- a/src/main/java/handiebot/command/commands/music/QueueCommand.java
+++ b/src/main/java/handiebot/command/commands/music/QueueCommand.java
@@ -8,6 +8,9 @@ import handiebot.lavaplayer.playlist.Playlist;
import handiebot.view.BotLog;
import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
import static handiebot.HandieBot.log;
import static handiebot.HandieBot.resourceBundle;
@@ -21,11 +24,12 @@ public class QueueCommand extends ContextCommand {
public QueueCommand() {
super("queue",
- "[all|clear|save]",
+ "[all|clear|save|remove]",
resourceBundle.getString("commands.command.queue.description.main")+"\n" +
"\t`all` - "+resourceBundle.getString("commands.command.queue.description.all")+"\n" +
"\t`clear` - "+resourceBundle.getString("commands.command.queue.description.clear")+"\n" +
- "\t`save ` - "+resourceBundle.getString("commands.command.queue.description.save"),
+ "\t`save ` - "+resourceBundle.getString("commands.command.queue.description.save")+"\n"+
+ "\t`remove ` - "+resourceBundle.getString("commands.command.queue.description.remove"),
0);
}
@@ -53,6 +57,21 @@ public class QueueCommand extends ContextCommand {
sendMessage(resourceBundle.getString("commands.command.queue.error.save"), context.getChannel());
}
break;
+ case ("remove"):
+ if (context.getArgs().length > 1 && Commands.hasPermission(context, 8)){
+ List songsToRemove = new ArrayList<>();
+ for (int i = 1; i < context.getArgs().length; i++){
+ songsToRemove.add(Integer.parseInt(context.getArgs()[i]));
+ }
+ songsToRemove.sort(Collections.reverseOrder());
+ for (Integer i : songsToRemove){
+ HandieBot.musicPlayer.getMusicManager(context.getGuild()).scheduler.remove(i-1);
+ }
+ sendMessage(resourceBundle.getString("commands.command.queue.remove.message"), context.getChannel());
+ log.log(BotLog.TYPE.MUSIC, context.getGuild(), resourceBundle.getString("commands.command.queue.remove.message"));
+ } else {
+ sendMessage(resourceBundle.getString("commands.command.queue.remove.error"), context.getChannel());
+ }
}
} else {
HandieBot.musicPlayer.showQueueList(context.getGuild(), false);
diff --git a/src/main/java/handiebot/command/commands/support/ReportCommand.java b/src/main/java/handiebot/command/commands/support/ReportCommand.java
new file mode 100644
index 0000000..94b1ac7
--- /dev/null
+++ b/src/main/java/handiebot/command/commands/support/ReportCommand.java
@@ -0,0 +1,73 @@
+package handiebot.command.commands.support;
+
+import handiebot.command.CommandContext;
+import handiebot.command.types.ContextCommand;
+import handiebot.utils.MessageUtils;
+import handiebot.view.BotLog;
+import sx.blah.discord.api.internal.json.objects.EmbedObject;
+import sx.blah.discord.handle.obj.IRole;
+import sx.blah.discord.handle.obj.IUser;
+import sx.blah.discord.handle.obj.Permissions;
+import sx.blah.discord.util.EmbedBuilder;
+
+import java.awt.*;
+import java.util.ArrayList;
+import java.util.List;
+
+import static handiebot.HandieBot.log;
+import static handiebot.HandieBot.resourceBundle;
+import static handiebot.utils.MessageUtils.sendMessage;
+
+/**
+ * @author Andrew Lalis
+ * Command to allow anyone to report a user, and have all administrators be notified of this report, and then
+ * choose a proper punishment.
+ */
+public class ReportCommand extends ContextCommand {
+
+
+ public ReportCommand() {
+ super("report",
+ " [REASON]",
+ resourceBundle.getString("commands.command.report.description"),
+ 0);
+ }
+
+ @Override
+ public void execute(CommandContext context) {
+ if (context.getArgs().length < 1){
+ sendMessage(resourceBundle.getString("commands.command.report.error"), context.getChannel());
+ return;
+ }
+ List roles = context.getGuild().getRoles();
+ List adminRoles = new ArrayList<>();
+ for (IRole role : roles){
+ if (role.getPermissions().contains(Permissions.VOICE_MUTE_MEMBERS) && role.getPermissions().contains(Permissions.VOICE_DEAFEN_MEMBERS)){
+ //The role has sufficient reason to be notified.
+ adminRoles.add(role);
+ }
+ }
+ EmbedBuilder builder = new EmbedBuilder();
+ builder.withTitle("Report");
+ builder.withColor(Color.red);
+ StringBuilder sb = new StringBuilder();
+ sb.append(context.getUser().mention()).append(" has reported ").append(context.getArgs()[0]).append(".");
+ if (context.getArgs().length > 1){
+ sb.append('\n').append("Reason: ").append(MessageUtils.getTextFromArgs(context.getArgs(), 1));
+ }
+ builder.withDescription(sb.toString());
+ EmbedObject eo = builder.build();
+ for (IUser user : context.getGuild().getUsers()){
+ if (!user.isBot()) {
+ for (IRole role : adminRoles) {
+ if (user.getRolesForGuild(context.getGuild()).contains(role)) {
+ //The user has sufficient reason to be notified.
+ user.getOrCreatePMChannel().sendMessage(eo);
+ break;
+ }
+ }
+ }
+ }
+ log.log(BotLog.TYPE.COMMAND, context.getGuild(), eo.description);
+ }
+}
diff --git a/src/main/java/handiebot/lavaplayer/TrackScheduler.java b/src/main/java/handiebot/lavaplayer/TrackScheduler.java
index 55d9cee..544678b 100644
--- a/src/main/java/handiebot/lavaplayer/TrackScheduler.java
+++ b/src/main/java/handiebot/lavaplayer/TrackScheduler.java
@@ -155,6 +155,16 @@ public class TrackScheduler extends AudioEventAdapter {
}
}
+ /**
+ * Removes a song at a specified index from the queue.
+ * @param songIndex The index of the song to remove.
+ */
+ public void remove(int songIndex){
+ if (songIndex >= 0 && songIndex < this.activePlaylist.getTrackCount()){
+ this.activePlaylist.getTracks().remove(songIndex);
+ }
+ }
+
/**
* Starts the next track, stopping the current one if it's playing.
*/
diff --git a/src/main/resources/Strings.properties b/src/main/resources/Strings.properties
index 7dbe15e..a848181 100644
--- a/src/main/resources/Strings.properties
+++ b/src/main/resources/Strings.properties
@@ -95,10 +95,13 @@ commands.command.queue.description.main=Shows the first 10 songs in the queue.
commands.command.queue.description.all=Shows all songs.
commands.command.queue.description.clear=Clears the queue and stops playing.
commands.command.queue.description.save=Saves the queue to a playlist.
+commands.command.queue.description.remove=Removes a song from the queue.
commands.command.queue.clear=Cleared queue.
commands.command.queue.save.message=Saved {0} tracks to playlist **{1}**.
commands.command.queue.save.log=Saved queue to playlist [{0}].
commands.command.queue.error.save=Unable to save the queue to a playlist.
+commands.command.queue.remove.message=Removed song(s) from the active queue.
+commands.command.queue.remove.error=You must give the index of a song to remove from the queue.
#Repeat
commands.command.repeat.description=Sets repeating.
#Shuffle
@@ -113,6 +116,9 @@ commands.command.tengwar.description=Translates text to tengwar, or decodes teng
commands.youtube.choiceMade.log={0} chose item {1} from the Youtube query.
commands.youtube.title=Showing the first {0} results from YouTube.com.
commands.youtube.footerInstruction=Please add a reaction to select a song, or cancel. Choice times out in 30 seconds.
+#Report
+commands.command.report.description=Reports a user to administrators.
+commands.command.report.error=You must name a user in your report.
#Music Player
player.setRepeat=Set **Repeat** to *{0}*.
player.setShuffle=Set **Shuffle** to *{0}*.
@@ -145,3 +151,6 @@ playlist.load.error.IOException=IOException while loading playlist [{0}]. {1}
playlist.load.error.exists=The playlist [{0}] does not exist.
+
+
+
diff --git a/src/main/resources/Strings_nl.properties b/src/main/resources/Strings_nl.properties
index b3eb818..1126c85 100644
--- a/src/main/resources/Strings_nl.properties
+++ b/src/main/resources/Strings_nl.properties
@@ -129,5 +129,9 @@ playlist.save.error.fileNotFound=Unable to find file to write playlist: {0}
playlist.load.IOException=IOException while loading playlist [{0}]. {1}
playlist.load.error.exists=The playlist [{0}] does not exist.
commands.youtube.footerInstruction=Please add a reaction to select a song, or cancel. Choice times out in 30 seconds.
+commands.command.report.description=Reports a user to administrators.
+commands.command.report.error=You must name a user in your report.
+commands.command.queue.remove=Removed song(s) from the active queue.
+commands.command.queue.remove.error=You must give the index of a song to remove from the queue.