From 35186a615f63f6927ab309054b61497d52b20bd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Av=C3=A9?= Date: Fri, 24 Nov 2023 11:13:52 +0100 Subject: [PATCH] Move overview to server list --- .../java/com/jagrosh/jmusicbot/JMusicBot.java | 1 - .../jmusicbot/commands/owner/OverviewCmd.java | 66 ------------------- .../jmusicbot/commands/owner/ServerCmd.java | 30 +++++++++ 3 files changed, 30 insertions(+), 67 deletions(-) delete mode 100644 src/main/java/com/jagrosh/jmusicbot/commands/owner/OverviewCmd.java diff --git a/src/main/java/com/jagrosh/jmusicbot/JMusicBot.java b/src/main/java/com/jagrosh/jmusicbot/JMusicBot.java index 152467c02..79a838d62 100644 --- a/src/main/java/com/jagrosh/jmusicbot/JMusicBot.java +++ b/src/main/java/com/jagrosh/jmusicbot/JMusicBot.java @@ -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), diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/owner/OverviewCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/owner/OverviewCmd.java deleted file mode 100644 index b3328c686..000000000 --- a/src/main/java/com/jagrosh/jmusicbot/commands/owner/OverviewCmd.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright 2016 John Grosh . - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.jagrosh.jmusicbot.commands.owner; - -import com.jagrosh.jdautilities.command.CommandEvent; -import com.jagrosh.jmusicbot.Bot; -import com.jagrosh.jmusicbot.audio.AudioHandler; -import com.jagrosh.jmusicbot.commands.OwnerCommand; -import com.sedmelluq.discord.lavaplayer.track.AudioTrack; -import net.dv8tion.jda.api.entities.Guild; - -public class OverviewCmd extends OwnerCommand -{ - private final Bot bot; - public OverviewCmd(Bot bot) - { - this.bot = bot; - this.guildOnly = false; - this.name = "overview"; - this.help = "provides an overview of what is currently being played by the bot"; - this.aliases = bot.getConfig().getAliases(this.name); - } - - @Override - public void execute(CommandEvent event) - { - 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()); - } -} diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/owner/ServerCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/owner/ServerCmd.java index cbf354d40..2f651f6bf 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/owner/ServerCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/owner/ServerCmd.java @@ -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; @@ -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; }