added queue remove and report commands.
This commit is contained in:
parent
7a4b3e8c36
commit
e1944c7447
2
pom.xml
2
pom.xml
|
@ -70,7 +70,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.andrewlalis</groupId>
|
<groupId>com.github.andrewlalis</groupId>
|
||||||
<artifactId>TengwarTranslatorLibrary</artifactId>
|
<artifactId>TengwarTranslatorLibrary</artifactId>
|
||||||
<version>1.3</version>
|
<version>1.3.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.google.apis</groupId>
|
<groupId>com.google.apis</groupId>
|
||||||
|
|
|
@ -7,6 +7,7 @@ import handiebot.command.commands.misc.TengwarCommand;
|
||||||
import handiebot.command.commands.music.*;
|
import handiebot.command.commands.music.*;
|
||||||
import handiebot.command.commands.support.HelpCommand;
|
import handiebot.command.commands.support.HelpCommand;
|
||||||
import handiebot.command.commands.support.InfoCommand;
|
import handiebot.command.commands.support.InfoCommand;
|
||||||
|
import handiebot.command.commands.support.ReportCommand;
|
||||||
import handiebot.command.types.Command;
|
import handiebot.command.types.Command;
|
||||||
import handiebot.command.types.ContextCommand;
|
import handiebot.command.types.ContextCommand;
|
||||||
import handiebot.command.types.StaticCommand;
|
import handiebot.command.types.StaticCommand;
|
||||||
|
@ -41,6 +42,7 @@ public class Commands {
|
||||||
//Other commands.
|
//Other commands.
|
||||||
commands.add(new HelpCommand());
|
commands.add(new HelpCommand());
|
||||||
commands.add(new InfoCommand());
|
commands.add(new InfoCommand());
|
||||||
|
commands.add(new ReportCommand());
|
||||||
commands.add(new SetPrefixCommand());
|
commands.add(new SetPrefixCommand());
|
||||||
commands.add(new QuitCommand());
|
commands.add(new QuitCommand());
|
||||||
commands.add(new BroadcastCommand());
|
commands.add(new BroadcastCommand());
|
||||||
|
|
|
@ -6,6 +6,8 @@ import handiebot.utils.MessageUtils;
|
||||||
import net.agspace.TengwarImageGenerator;
|
import net.agspace.TengwarImageGenerator;
|
||||||
import net.agspace.Translator;
|
import net.agspace.Translator;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
import static handiebot.HandieBot.resourceBundle;
|
import static handiebot.HandieBot.resourceBundle;
|
||||||
import static handiebot.utils.MessageUtils.sendFile;
|
import static handiebot.utils.MessageUtils.sendFile;
|
||||||
import static handiebot.utils.MessageUtils.sendMessage;
|
import static handiebot.utils.MessageUtils.sendMessage;
|
||||||
|
@ -35,7 +37,9 @@ public class TengwarCommand extends ContextCommand {
|
||||||
24f,
|
24f,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
System.getProperty("user.home")+"/.handiebot/tengwarTemp.png"),
|
System.getProperty("user.home")+"/.handiebot/tengwarTemp.png",
|
||||||
|
Color.white,
|
||||||
|
Color.black),
|
||||||
"Raw text: `" +result+'`',
|
"Raw text: `" +result+'`',
|
||||||
context.getChannel());
|
context.getChannel());
|
||||||
} else if (context.getArgs()[0].equalsIgnoreCase("from")){
|
} else if (context.getArgs()[0].equalsIgnoreCase("from")){
|
||||||
|
|
|
@ -8,6 +8,9 @@ import handiebot.lavaplayer.playlist.Playlist;
|
||||||
import handiebot.view.BotLog;
|
import handiebot.view.BotLog;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
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.log;
|
||||||
import static handiebot.HandieBot.resourceBundle;
|
import static handiebot.HandieBot.resourceBundle;
|
||||||
|
@ -21,11 +24,12 @@ public class QueueCommand extends ContextCommand {
|
||||||
|
|
||||||
public QueueCommand() {
|
public QueueCommand() {
|
||||||
super("queue",
|
super("queue",
|
||||||
"[all|clear|save]",
|
"[all|clear|save|remove]",
|
||||||
resourceBundle.getString("commands.command.queue.description.main")+"\n" +
|
resourceBundle.getString("commands.command.queue.description.main")+"\n" +
|
||||||
"\t`all` - "+resourceBundle.getString("commands.command.queue.description.all")+"\n" +
|
"\t`all` - "+resourceBundle.getString("commands.command.queue.description.all")+"\n" +
|
||||||
"\t`clear` - "+resourceBundle.getString("commands.command.queue.description.clear")+"\n" +
|
"\t`clear` - "+resourceBundle.getString("commands.command.queue.description.clear")+"\n" +
|
||||||
"\t`save <PLAYLIST>` - "+resourceBundle.getString("commands.command.queue.description.save"),
|
"\t`save <PLAYLIST>` - "+resourceBundle.getString("commands.command.queue.description.save")+"\n"+
|
||||||
|
"\t`remove <INDEX| INDEX2...>` - "+resourceBundle.getString("commands.command.queue.description.remove"),
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +57,21 @@ public class QueueCommand extends ContextCommand {
|
||||||
sendMessage(resourceBundle.getString("commands.command.queue.error.save"), context.getChannel());
|
sendMessage(resourceBundle.getString("commands.command.queue.error.save"), context.getChannel());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case ("remove"):
|
||||||
|
if (context.getArgs().length > 1 && Commands.hasPermission(context, 8)){
|
||||||
|
List<Integer> 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 {
|
} else {
|
||||||
HandieBot.musicPlayer.showQueueList(context.getGuild(), false);
|
HandieBot.musicPlayer.showQueueList(context.getGuild(), false);
|
||||||
|
|
|
@ -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",
|
||||||
|
"<USER> [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<IRole> roles = context.getGuild().getRoles();
|
||||||
|
List<IRole> 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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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.
|
* Starts the next track, stopping the current one if it's playing.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -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.all=Shows all songs.
|
||||||
commands.command.queue.description.clear=Clears the queue and stops playing.
|
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.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.clear=Cleared queue.
|
||||||
commands.command.queue.save.message=Saved {0} tracks to playlist **{1}**.
|
commands.command.queue.save.message=Saved {0} tracks to playlist **{1}**.
|
||||||
commands.command.queue.save.log=Saved queue to playlist [{0}].
|
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.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
|
#Repeat
|
||||||
commands.command.repeat.description=Sets repeating.
|
commands.command.repeat.description=Sets repeating.
|
||||||
#Shuffle
|
#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.choiceMade.log={0} chose item {1} from the Youtube query.
|
||||||
commands.youtube.title=Showing the first {0} results from YouTube.com.
|
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.
|
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
|
#Music Player
|
||||||
player.setRepeat=Set **Repeat** to *{0}*.
|
player.setRepeat=Set **Repeat** to *{0}*.
|
||||||
player.setShuffle=Set **Shuffle** 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.
|
playlist.load.error.exists=The playlist [{0}] does not exist.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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.IOException=IOException while loading playlist [{0}]. {1}
|
||||||
playlist.load.error.exists=The playlist [{0}] does not exist.
|
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.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.
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue