Info Command

This commit is contained in:
GregTCLTK 2019-12-28 14:14:45 +01:00
parent bf5d3c8364
commit 8d19b9ae07
No known key found for this signature in database
GPG key ID: A91BADE5C070FF67
3 changed files with 14 additions and 15 deletions

View file

@ -11,19 +11,16 @@ import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
public class InfoCommand implements Command { public class InfoCommand implements Command {
private static final String CD = "\uD83D\uDCBF";
private static final String MIC = "\uD83C\uDFA4";
private static final String QUEUE_DESCRIPTION = "%s **|>** %s\n%s\n%s %s\n%s";
@Override @Override
public void executed(String[] args, CommandEvent event) { public void executed(String[] args, CommandEvent event) {
if (event.getAudioManager().hasPlayer(event.getGuild()) && event.getAudioManager().getPlayer(event.getGuild()).getPlayingTrack() == null) { if (event.getAudioManager().hasPlayer(event.getGuild()) && event.getAudioManager().getPlayer(event.getGuild()).getPlayingTrack() != null) {
AudioTrack track = event.getAudioManager().getPlayer(event.getGuild()).getPlayingTrack(); AudioTrack track = event.getAudioManager().getPlayer(event.getGuild()).getPlayingTrack();
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO, "", "", "", "").build()).queue(); event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.INFO,
event.getTextChannel().sendMessage("Track Info" + String.format(QUEUE_DESCRIPTION, CD, event.getAudioManager().getOrNull(track.getInfo().title), "commands.music.info.success.title", "")
"\n\u23F1 **|>** `[ " + event.getAudioManager().getTimestamp(track.getPosition()) + " / " + event.getAudioManager().getTimestamp(track.getInfo().length) + " ]`", .setAuthor(track.getInfo().author)
"\n" + MIC, event.getAudioManager().getOrNull(track.getInfo().author), .addField("Title", track.getInfo().title, true)
"\n\uD83C\uDFA7 **|>** " + "")).queue(); .addField("Progress", "`[ " + event.getAudioManager().getTimestamp(track.getPosition()) + " / " + event.getAudioManager().getTimestamp(track.getInfo().length) + " ]`", false)
.build()).queue();
} else { } else {
event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR, event.getTextChannel().sendMessage(event.getMessageEditor().getMessage(MessageEditor.MessageType.ERROR,
"commands.music.info.error.title", "commands.music.info.error.title",
@ -38,7 +35,7 @@ public class InfoCommand implements Command {
@Override @Override
public String description() { public String description() {
return "Shows information about the playing song"; return "commands.music.info.help.description";
} }
@Override @Override

View file

@ -44,7 +44,7 @@ public class EvalCommand implements Command {
engine.put("author", event.getAuthor()); engine.put("author", event.getAuthor());
engine.put("member", event.getMember()); engine.put("member", event.getMember());
engine.put("self", event.getGuild().getSelfMember()); engine.put("self", event.getGuild().getSelfMember());
engine.put("audio", new AudioManager()); engine.put("audio", event.getAudioManager());
engine.put("out", System.out); engine.put("out", System.out);
ScheduledExecutorService service = Executors.newScheduledThreadPool(1); ScheduledExecutorService service = Executors.newScheduledThreadPool(1);
@ -55,12 +55,12 @@ public class EvalCommand implements Command {
Object out; Object out;
try { try {
String script = ""; StringBuilder script = new StringBuilder();
for (int i = 0; i < args.length; i++) { for (int i = 0; i < args.length; i++) {
args[i] = args[i].replace("```java", "").replace("```", ""); args[i] = args[i].replace("```java", "").replace("```", "");
script += i == args.length - 1 ? args[i] : args[i] + " "; script.append(i == args.length - 1 ? args[i] : args[i] + " ");
} }
out = engine.eval(script); out = engine.eval(script.toString());
event.getTextChannel().sendMessage(event.getMessageEditor() event.getTextChannel().sendMessage(event.getMessageEditor()
.getMessage(MessageEditor.MessageType.INFO, "commands.owner.eval.success.title", "") .getMessage(MessageEditor.MessageType.INFO, "commands.owner.eval.success.title", "")

View file

@ -203,8 +203,10 @@ commands.music.play.success.length = Length
commands.music.play.help.description = Plays a song commands.music.play.help.description = Plays a song
commands.music.stop.success.title = Successfully stopped commands.music.stop.success.title = Successfully stopped
commands.music.stop.success.description = I successfully stopped the song. commands.music.stop.success.description = I successfully stopped the song.
commands.music.info.success.title = Track info
commands.music.info.error.title = No playing track commands.music.info.error.title = No playing track
commands.music.info.error.description = I am not playing anything at the moment commands.music.info.error.description = I am not playing anything at the moment
commands.music.info.help.description = Shows information about the playing song
commands.music.stop.help.description = Stops the song commands.music.stop.help.description = Stops the song
commands.music.queue.error.title = No queue commands.music.queue.error.title = No queue
commands.music.queue.error.description = There are no queued songs at the moment commands.music.queue.error.description = There are no queued songs at the moment