Skip to content

Commit

Permalink
Move overview to server list
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasave committed Nov 24, 2023
1 parent bce671b commit 35186a6
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 67 deletions.
1 change: 0 additions & 1 deletion src/main/java/com/jagrosh/jmusicbot/JMusicBot.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,6 @@ private static void startBot()

new AutoplaylistCmd(bot),
new DebugCmd(bot),
new OverviewCmd(bot),
new ServerCmd(bot),
new PlaylistCmd(bot),
new SetavatarCmd(bot),
Expand Down

This file was deleted.

30 changes: 30 additions & 0 deletions src/main/java/com/jagrosh/jmusicbot/commands/owner/ServerCmd.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@
import com.jagrosh.jdautilities.command.CommandEvent;
import com.jagrosh.jdautilities.examples.command.PingCommand;
import com.jagrosh.jmusicbot.Bot;
import com.jagrosh.jmusicbot.audio.AudioHandler;
import com.jagrosh.jmusicbot.commands.OwnerCommand;
import com.jagrosh.jmusicbot.commands.admin.*;
import com.jagrosh.jmusicbot.commands.dj.*;
import com.jagrosh.jmusicbot.commands.general.SettingsCmd;
import com.jagrosh.jmusicbot.commands.music.*;
import com.jagrosh.jmusicbot.utils.CustomMessage;
import com.sedmelluq.discord.lavaplayer.track.AudioTrack;
import net.dv8tion.jda.api.entities.*;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import org.slf4j.Logger;
Expand All @@ -48,6 +50,34 @@ public ServerCmd(Bot bot) {
@Override
public void execute(CommandEvent event) {
String[] parts = event.getArgs().split("\\s+", 3);
if (parts.length > 0 && parts[0].equals("list")) {
StringBuilder playing = new StringBuilder();
StringBuilder empty = new StringBuilder();
playing.append("Currently playing:\n");
empty.append("Currently inactive:\n");
for (Guild g: bot.getJDA().getGuilds()) {
AudioHandler handler = (AudioHandler)g.getAudioManager().getSendingHandler();
if (handler != null) {
AudioTrack track = handler.getPlayer().getPlayingTrack();
playing.append("- ")
.append(g.getName())
.append(" [")
.append(g.getId())
.append("]: ")
.append(track.getInfo().title)
.append("\n");
} else {
empty.append("- ")
.append(g.getName())
.append(" [")
.append(g.getId())
.append("]\n");
}
}
playing.append(empty);
event.reply(playing.toString());
return;
}
if (parts.length < 2) {
return;
}
Expand Down

0 comments on commit 35186a6

Please sign in to comment.