From 7192d55732b3475e353752c3ed46175149768c42 Mon Sep 17 00:00:00 2001 From: MichailiK <39029839+MichailiK@users.noreply.github.com> Date: Fri, 25 Oct 2019 17:51:56 +0200 Subject: [PATCH 1/7] Add configurable aliases for all commands --- .../java/com/jagrosh/jmusicbot/BotConfig.java | 13 +++- .../java/com/jagrosh/jmusicbot/JMusicBot.java | 3 +- .../jmusicbot/commands/admin/SetdjCmd.java | 2 + .../jmusicbot/commands/admin/SettcCmd.java | 2 + .../jmusicbot/commands/admin/SetvcCmd.java | 2 + .../jmusicbot/commands/dj/ForceRemoveCmd.java | 3 +- .../jmusicbot/commands/dj/ForceskipCmd.java | 3 +- .../jmusicbot/commands/dj/MoveTrackCmd.java | 3 +- .../jmusicbot/commands/dj/PauseCmd.java | 2 + .../jmusicbot/commands/dj/PlaynextCmd.java | 2 + .../jmusicbot/commands/dj/RepeatCmd.java | 2 + .../jmusicbot/commands/dj/SkiptoCmd.java | 3 +- .../jmusicbot/commands/dj/StopCmd.java | 2 + .../jmusicbot/commands/dj/VolumeCmd.java | 3 +- .../commands/general/SettingsCmd.java | 3 +- .../jmusicbot/commands/music/LyricsCmd.java | 2 + .../commands/music/NowplayingCmd.java | 3 +- .../jmusicbot/commands/music/PlayCmd.java | 2 + .../commands/music/PlaylistsCmd.java | 3 +- .../jmusicbot/commands/music/QueueCmd.java | 2 +- .../jmusicbot/commands/music/RemoveCmd.java | 3 +- .../jmusicbot/commands/music/SCSearchCmd.java | 3 +- .../jmusicbot/commands/music/SearchCmd.java | 3 +- .../jmusicbot/commands/music/ShuffleCmd.java | 2 + .../jmusicbot/commands/music/SkipCmd.java | 3 +- .../commands/owner/AutoplaylistCmd.java | 2 + .../jmusicbot/commands/owner/DebugCmd.java | 2 + .../jmusicbot/commands/owner/EvalCmd.java | 2 + .../jmusicbot/commands/owner/PlaylistCmd.java | 2 + .../commands/owner/SetavatarCmd.java | 2 + .../jmusicbot/commands/owner/SetgameCmd.java | 2 + .../jmusicbot/commands/owner/SetnameCmd.java | 2 + .../commands/owner/SetstatusCmd.java | 2 + .../jmusicbot/commands/owner/ShutdownCmd.java | 2 + src/main/resources/reference.conf | 60 +++++++++++++++++++ 35 files changed, 136 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/jagrosh/jmusicbot/BotConfig.java b/src/main/java/com/jagrosh/jmusicbot/BotConfig.java index cec94c0..5cfb8e5 100644 --- a/src/main/java/com/jagrosh/jmusicbot/BotConfig.java +++ b/src/main/java/com/jagrosh/jmusicbot/BotConfig.java @@ -46,7 +46,8 @@ public class BotConfig private long owner, maxSeconds; private OnlineStatus status; private Game game; - + + private Config config; private boolean valid = false; public BotConfig(Prompt prompt) @@ -72,7 +73,7 @@ public class BotConfig // load in the config file, plus the default values //Config config = ConfigFactory.parseFile(path.toFile()).withFallback(ConfigFactory.load()); - Config config = ConfigFactory.load(); + config = ConfigFactory.load(); // set values token = config.getString("token"); @@ -300,4 +301,12 @@ public class BotConfig return false; return Math.round(track.getDuration()/1000.0) > maxSeconds; } + + public String[] getAliases(String command) + { + String aliases = config.getString("alias."+command); + if(aliases == null || aliases.length() <= 0) + return new String[]{}; + return aliases.split(" "); + } } diff --git a/src/main/java/com/jagrosh/jmusicbot/JMusicBot.java b/src/main/java/com/jagrosh/jmusicbot/JMusicBot.java index a65eae5..6be2c93 100644 --- a/src/main/java/com/jagrosh/jmusicbot/JMusicBot.java +++ b/src/main/java/com/jagrosh/jmusicbot/JMusicBot.java @@ -46,6 +46,7 @@ public class JMusicBot public final static Permission[] RECOMMENDED_PERMS = new Permission[]{Permission.MESSAGE_READ, Permission.MESSAGE_WRITE, Permission.MESSAGE_HISTORY, Permission.MESSAGE_ADD_REACTION, Permission.MESSAGE_EMBED_LINKS, Permission.MESSAGE_ATTACH_FILES, Permission.MESSAGE_MANAGE, Permission.MESSAGE_EXT_EMOJI, Permission.MANAGE_CHANNEL, Permission.VOICE_CONNECT, Permission.VOICE_SPEAK, Permission.NICKNAME_CHANGE}; + public static BotConfig config; /** * @param args the command line arguments */ @@ -71,7 +72,7 @@ public class JMusicBot String version = OtherUtil.checkVersion(prompt); // load config - BotConfig config = new BotConfig(prompt); + config = new BotConfig(prompt); config.load(); if(!config.isValid()) return; diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetdjCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetdjCmd.java index befe637..3423461 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetdjCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetdjCmd.java @@ -18,6 +18,7 @@ package com.jagrosh.jmusicbot.commands.admin; import java.util.List; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jdautilities.commons.utils.FinderUtil; +import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.commands.AdminCommand; import com.jagrosh.jmusicbot.settings.Settings; import com.jagrosh.jmusicbot.utils.FormatUtil; @@ -34,6 +35,7 @@ public class SetdjCmd extends AdminCommand this.name = "setdj"; this.help = "sets the DJ role for certain music commands"; this.arguments = ""; + this.aliases = JMusicBot.config.getAliases(this.name); } @Override diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/admin/SettcCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/admin/SettcCmd.java index 6c408c0..3d750be 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/admin/SettcCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/admin/SettcCmd.java @@ -18,6 +18,7 @@ package com.jagrosh.jmusicbot.commands.admin; import java.util.List; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jdautilities.commons.utils.FinderUtil; +import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.commands.AdminCommand; import com.jagrosh.jmusicbot.settings.Settings; import com.jagrosh.jmusicbot.utils.FormatUtil; @@ -34,6 +35,7 @@ public class SettcCmd extends AdminCommand this.name = "settc"; this.help = "sets the text channel for music commands"; this.arguments = ""; + this.aliases = JMusicBot.config.getAliases(this.name); } @Override diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetvcCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetvcCmd.java index 15296cf..a106438 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetvcCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetvcCmd.java @@ -18,6 +18,7 @@ package com.jagrosh.jmusicbot.commands.admin; import java.util.List; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jdautilities.commons.utils.FinderUtil; +import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.commands.AdminCommand; import com.jagrosh.jmusicbot.settings.Settings; import com.jagrosh.jmusicbot.utils.FormatUtil; @@ -34,6 +35,7 @@ public class SetvcCmd extends AdminCommand this.name = "setvc"; this.help = "sets the voice channel for playing music"; this.arguments = ""; + this.aliases = JMusicBot.config.getAliases(this.name); } @Override diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/dj/ForceRemoveCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/dj/ForceRemoveCmd.java index e18534d..5aa1c1c 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/dj/ForceRemoveCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/dj/ForceRemoveCmd.java @@ -19,6 +19,7 @@ import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jdautilities.commons.utils.FinderUtil; import com.jagrosh.jdautilities.menu.OrderedMenu; import com.jagrosh.jmusicbot.Bot; +import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.audio.AudioHandler; import com.jagrosh.jmusicbot.commands.DJCommand; import net.dv8tion.jda.core.Permission; @@ -40,7 +41,7 @@ public class ForceRemoveCmd extends DJCommand this.name = "forceremove"; this.help = "removes all entries by a user from the queue"; this.arguments = ""; - this.aliases = new String[]{"forcedelete", "modremove", "moddelete"}; + this.aliases = JMusicBot.config.getAliases(this.name); this.beListening = false; this.bePlaying = true; this.botPermissions = new Permission[]{Permission.MESSAGE_EMBED_LINKS}; diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/dj/ForceskipCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/dj/ForceskipCmd.java index 7413a2b..a2d79dc 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/dj/ForceskipCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/dj/ForceskipCmd.java @@ -17,6 +17,7 @@ package com.jagrosh.jmusicbot.commands.dj; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; +import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.audio.AudioHandler; import com.jagrosh.jmusicbot.commands.DJCommand; import net.dv8tion.jda.core.entities.User; @@ -32,7 +33,7 @@ public class ForceskipCmd extends DJCommand super(bot); this.name = "forceskip"; this.help = "skips the current song"; - this.aliases = new String[]{"modskip"}; + this.aliases = JMusicBot.config.getAliases(this.name); this.bePlaying = true; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/dj/MoveTrackCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/dj/MoveTrackCmd.java index 0275342..b4f0945 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/dj/MoveTrackCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/dj/MoveTrackCmd.java @@ -3,6 +3,7 @@ package com.jagrosh.jmusicbot.commands.dj; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; +import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.audio.AudioHandler; import com.jagrosh.jmusicbot.audio.QueuedTrack; import com.jagrosh.jmusicbot.commands.DJCommand; @@ -20,7 +21,7 @@ public class MoveTrackCmd extends DJCommand this.name = "movetrack"; this.help = "move a track in the current queue to a different position"; this.arguments = " "; - this.aliases = new String[]{"move"}; + this.aliases = JMusicBot.config.getAliases(this.name); this.bePlaying = true; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/dj/PauseCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/dj/PauseCmd.java index 4c5a3b1..c374fb2 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/dj/PauseCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/dj/PauseCmd.java @@ -17,6 +17,7 @@ package com.jagrosh.jmusicbot.commands.dj; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; +import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.audio.AudioHandler; import com.jagrosh.jmusicbot.commands.DJCommand; @@ -31,6 +32,7 @@ public class PauseCmd extends DJCommand super(bot); this.name = "pause"; this.help = "pauses the current song"; + this.aliases = JMusicBot.config.getAliases(this.name); this.bePlaying = true; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/dj/PlaynextCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/dj/PlaynextCmd.java index b547210..9c2b277 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/dj/PlaynextCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/dj/PlaynextCmd.java @@ -17,6 +17,7 @@ package com.jagrosh.jmusicbot.commands.dj; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; +import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.audio.AudioHandler; import com.jagrosh.jmusicbot.audio.QueuedTrack; import com.jagrosh.jmusicbot.commands.DJCommand; @@ -42,6 +43,7 @@ public class PlaynextCmd extends DJCommand this.name = "playnext"; this.arguments = ""; this.help = "plays a single song next"; + this.aliases = JMusicBot.config.getAliases(this.name); this.beListening = true; this.bePlaying = false; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/dj/RepeatCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/dj/RepeatCmd.java index 693dc74..183d7da 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/dj/RepeatCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/dj/RepeatCmd.java @@ -17,6 +17,7 @@ package com.jagrosh.jmusicbot.commands.dj; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; +import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.commands.DJCommand; import com.jagrosh.jmusicbot.settings.Settings; @@ -32,6 +33,7 @@ public class RepeatCmd extends DJCommand this.name = "repeat"; this.help = "re-adds music to the queue when finished"; this.arguments = "[on|off]"; + this.aliases = JMusicBot.config.getAliases(this.name); this.guildOnly = true; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/dj/SkiptoCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/dj/SkiptoCmd.java index e8b95d2..9eb2ce1 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/dj/SkiptoCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/dj/SkiptoCmd.java @@ -17,6 +17,7 @@ package com.jagrosh.jmusicbot.commands.dj; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; +import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.audio.AudioHandler; import com.jagrosh.jmusicbot.commands.DJCommand; @@ -32,7 +33,7 @@ public class SkiptoCmd extends DJCommand this.name = "skipto"; this.help = "skips to the specified song"; this.arguments = ""; - this.aliases = new String[]{"jumpto"}; + this.aliases = JMusicBot.config.getAliases(this.name); this.bePlaying = true; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/dj/StopCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/dj/StopCmd.java index 53c292b..b8d6700 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/dj/StopCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/dj/StopCmd.java @@ -17,6 +17,7 @@ package com.jagrosh.jmusicbot.commands.dj; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; +import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.audio.AudioHandler; import com.jagrosh.jmusicbot.commands.DJCommand; @@ -31,6 +32,7 @@ public class StopCmd extends DJCommand super(bot); this.name = "stop"; this.help = "stops the current song and clears the queue"; + this.aliases = JMusicBot.config.getAliases(this.name); this.bePlaying = false; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/dj/VolumeCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/dj/VolumeCmd.java index 40acb7e..c45e741 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/dj/VolumeCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/dj/VolumeCmd.java @@ -17,6 +17,7 @@ package com.jagrosh.jmusicbot.commands.dj; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; +import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.audio.AudioHandler; import com.jagrosh.jmusicbot.commands.DJCommand; import com.jagrosh.jmusicbot.settings.Settings; @@ -32,7 +33,7 @@ public class VolumeCmd extends DJCommand { super(bot); this.name = "volume"; - this.aliases = new String[]{"vol"}; + this.aliases = JMusicBot.config.getAliases(this.name); this.help = "sets or shows volume"; this.arguments = "[0-150]"; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/general/SettingsCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/general/SettingsCmd.java index ceb2138..899e544 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/general/SettingsCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/general/SettingsCmd.java @@ -17,6 +17,7 @@ package com.jagrosh.jmusicbot.commands.general; import com.jagrosh.jdautilities.command.Command; import com.jagrosh.jdautilities.command.CommandEvent; +import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.settings.Settings; import net.dv8tion.jda.core.EmbedBuilder; import net.dv8tion.jda.core.MessageBuilder; @@ -36,7 +37,7 @@ public class SettingsCmd extends Command { this.name = "settings"; this.help = "shows the bots settings"; - this.aliases = new String[]{"status"}; + this.aliases = JMusicBot.config.getAliases(this.name); this.guildOnly = true; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/music/LyricsCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/music/LyricsCmd.java index 1d408f1..89feb43 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/music/LyricsCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/music/LyricsCmd.java @@ -19,6 +19,7 @@ import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jlyrics.Lyrics; import com.jagrosh.jlyrics.LyricsClient; import com.jagrosh.jmusicbot.Bot; +import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.audio.AudioHandler; import com.jagrosh.jmusicbot.commands.MusicCommand; import java.util.concurrent.ExecutionException; @@ -39,6 +40,7 @@ public class LyricsCmd extends MusicCommand this.name = "lyrics"; this.arguments = "[song name]"; this.help = "shows the lyrics to the currently-playing song"; + this.aliases = JMusicBot.config.getAliases(this.name); this.botPermissions = new Permission[]{Permission.MESSAGE_EMBED_LINKS}; this.bePlaying = true; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/music/NowplayingCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/music/NowplayingCmd.java index e7be1c1..6350369 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/music/NowplayingCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/music/NowplayingCmd.java @@ -17,6 +17,7 @@ package com.jagrosh.jmusicbot.commands.music; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; +import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.audio.AudioHandler; import com.jagrosh.jmusicbot.commands.MusicCommand; import net.dv8tion.jda.core.Permission; @@ -33,7 +34,7 @@ public class NowplayingCmd extends MusicCommand super(bot); this.name = "nowplaying"; this.help = "shows the song that is currently playing"; - this.aliases = new String[]{"np","current"}; + this.aliases = JMusicBot.config.getAliases(this.name); this.botPermissions = new Permission[]{Permission.MESSAGE_EMBED_LINKS}; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/music/PlayCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/music/PlayCmd.java index eb77b82..ccf711a 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/music/PlayCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/music/PlayCmd.java @@ -15,6 +15,7 @@ */ package com.jagrosh.jmusicbot.commands.music; +import com.jagrosh.jmusicbot.JMusicBot; import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler; import com.sedmelluq.discord.lavaplayer.tools.FriendlyException; import com.sedmelluq.discord.lavaplayer.tools.FriendlyException.Severity; @@ -53,6 +54,7 @@ public class PlayCmd extends MusicCommand this.name = "play"; this.arguments = ""; this.help = "plays the provided song"; + this.aliases = JMusicBot.config.getAliases(this.name); this.beListening = true; this.bePlaying = false; this.children = new Command[]{new PlaylistCmd(bot)}; diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/music/PlaylistsCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/music/PlaylistsCmd.java index 9aa73ae..04cc071 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/music/PlaylistsCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/music/PlaylistsCmd.java @@ -18,6 +18,7 @@ package com.jagrosh.jmusicbot.commands.music; import java.util.List; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; +import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.commands.MusicCommand; /** @@ -31,7 +32,7 @@ public class PlaylistsCmd extends MusicCommand super(bot); this.name = "playlists"; this.help = "shows the available playlists"; - this.aliases = new String[]{"pls"}; + this.aliases = JMusicBot.config.getAliases(this.name); this.guildOnly = true; this.beListening = false; this.beListening = false; diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/music/QueueCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/music/QueueCmd.java index fa7e0f5..a503fc1 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/music/QueueCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/music/QueueCmd.java @@ -47,7 +47,7 @@ public class QueueCmd extends MusicCommand this.name = "queue"; this.help = "shows the current queue"; this.arguments = "[pagenum]"; - this.aliases = new String[]{"list"}; + this.aliases = JMusicBot.config.getAliases(this.name); this.bePlaying = true; this.botPermissions = new Permission[]{Permission.MESSAGE_ADD_REACTION,Permission.MESSAGE_EMBED_LINKS}; builder = new Paginator.Builder() diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/music/RemoveCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/music/RemoveCmd.java index 2878c99..d6ddfa0 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/music/RemoveCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/music/RemoveCmd.java @@ -17,6 +17,7 @@ package com.jagrosh.jmusicbot.commands.music; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; +import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.audio.AudioHandler; import com.jagrosh.jmusicbot.audio.QueuedTrack; import com.jagrosh.jmusicbot.commands.MusicCommand; @@ -36,7 +37,7 @@ public class RemoveCmd extends MusicCommand this.name = "remove"; this.help = "removes a song from the queue"; this.arguments = ""; - this.aliases = new String[]{"delete"}; + this.aliases = JMusicBot.config.getAliases(this.name); this.beListening = true; this.bePlaying = true; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/music/SCSearchCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/music/SCSearchCmd.java index 2a10645..a908e0d 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/music/SCSearchCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/music/SCSearchCmd.java @@ -16,6 +16,7 @@ package com.jagrosh.jmusicbot.commands.music; import com.jagrosh.jmusicbot.Bot; +import com.jagrosh.jmusicbot.JMusicBot; /** * @@ -29,6 +30,6 @@ public class SCSearchCmd extends SearchCmd this.searchPrefix = "scsearch:"; this.name = "scsearch"; this.help = "searches Soundcloud for a provided query"; - this.aliases = new String[]{}; + this.aliases = JMusicBot.config.getAliases(this.name); } } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/music/SearchCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/music/SearchCmd.java index caaf2e1..7d413bb 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/music/SearchCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/music/SearchCmd.java @@ -15,6 +15,7 @@ */ package com.jagrosh.jmusicbot.commands.music; +import com.jagrosh.jmusicbot.JMusicBot; import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler; import com.sedmelluq.discord.lavaplayer.tools.FriendlyException; import com.sedmelluq.discord.lavaplayer.tools.FriendlyException.Severity; @@ -46,7 +47,7 @@ public class SearchCmd extends MusicCommand super(bot); this.searchingEmoji = bot.getConfig().getSearching(); this.name = "search"; - this.aliases = new String[]{"ytsearch"}; + this.aliases = JMusicBot.config.getAliases(this.name); this.arguments = ""; this.help = "searches Youtube for a provided query"; this.beListening = true; diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/music/ShuffleCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/music/ShuffleCmd.java index 4b817e3..68421b7 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/music/ShuffleCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/music/ShuffleCmd.java @@ -17,6 +17,7 @@ package com.jagrosh.jmusicbot.commands.music; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; +import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.audio.AudioHandler; import com.jagrosh.jmusicbot.commands.MusicCommand; @@ -31,6 +32,7 @@ public class ShuffleCmd extends MusicCommand super(bot); this.name = "shuffle"; this.help = "shuffles songs you have added"; + this.aliases = JMusicBot.config.getAliases(this.name); this.beListening = true; this.bePlaying = true; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/music/SkipCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/music/SkipCmd.java index 7fcedf8..9604e1c 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/music/SkipCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/music/SkipCmd.java @@ -17,6 +17,7 @@ package com.jagrosh.jmusicbot.commands.music; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; +import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.audio.AudioHandler; import com.jagrosh.jmusicbot.commands.MusicCommand; import net.dv8tion.jda.core.entities.User; @@ -32,7 +33,7 @@ public class SkipCmd extends MusicCommand super(bot); this.name = "skip"; this.help = "votes to skip the current song"; - this.aliases = new String[]{"voteskip"}; + this.aliases = JMusicBot.config.getAliases(this.name); this.beListening = true; this.bePlaying = true; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/owner/AutoplaylistCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/owner/AutoplaylistCmd.java index 7eff824..a908bba 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/owner/AutoplaylistCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/owner/AutoplaylistCmd.java @@ -17,6 +17,7 @@ package com.jagrosh.jmusicbot.commands.owner; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; +import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.commands.OwnerCommand; import com.jagrosh.jmusicbot.settings.Settings; @@ -35,6 +36,7 @@ public class AutoplaylistCmd extends OwnerCommand this.name = "autoplaylist"; this.arguments = ""; this.help = "sets the default playlist for the server"; + this.aliases = JMusicBot.config.getAliases(this.name); } @Override diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/owner/DebugCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/owner/DebugCmd.java index 39ad0a9..8b29ce3 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/owner/DebugCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/owner/DebugCmd.java @@ -18,6 +18,7 @@ package com.jagrosh.jmusicbot.commands.owner; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jdautilities.commons.JDAUtilitiesInfo; import com.jagrosh.jmusicbot.Bot; +import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.commands.OwnerCommand; import com.jagrosh.jmusicbot.utils.OtherUtil; import com.sedmelluq.discord.lavaplayer.tools.PlayerLibrary; @@ -41,6 +42,7 @@ public class DebugCmd extends OwnerCommand this.bot = bot; this.name = "debug"; this.help = "shows debug info"; + this.aliases = JMusicBot.config.getAliases(this.name); this.guildOnly = false; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/owner/EvalCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/owner/EvalCmd.java index 0fdcef0..82e6d94 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/owner/EvalCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/owner/EvalCmd.java @@ -19,6 +19,7 @@ import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; +import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.commands.OwnerCommand; /** @@ -34,6 +35,7 @@ public class EvalCmd extends OwnerCommand this.bot = bot; this.name = "eval"; this.help = "evaluates nashorn code"; + this.aliases = JMusicBot.config.getAliases(this.name); this.guildOnly = false; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/owner/PlaylistCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/owner/PlaylistCmd.java index 6c8982a..5167e5c 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/owner/PlaylistCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/owner/PlaylistCmd.java @@ -20,6 +20,7 @@ import java.util.List; import com.jagrosh.jdautilities.command.Command; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; +import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.commands.OwnerCommand; import com.jagrosh.jmusicbot.commands.owner.AutoplaylistCmd; import com.jagrosh.jmusicbot.playlist.PlaylistLoader.Playlist; @@ -38,6 +39,7 @@ public class PlaylistCmd extends OwnerCommand this.name = "playlist"; this.arguments = ""; this.help = "playlist management"; + this.aliases = JMusicBot.config.getAliases(this.name); this.children = new OwnerCommand[]{ new ListCmd(), new AppendlistCmd(), diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetavatarCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetavatarCmd.java index 13f83da..c0b877a 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetavatarCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetavatarCmd.java @@ -18,6 +18,7 @@ package com.jagrosh.jmusicbot.commands.owner; import java.io.IOException; import java.io.InputStream; import com.jagrosh.jdautilities.command.CommandEvent; +import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.commands.OwnerCommand; import com.jagrosh.jmusicbot.utils.OtherUtil; import net.dv8tion.jda.core.entities.Icon; @@ -33,6 +34,7 @@ public class SetavatarCmd extends OwnerCommand this.name = "setavatar"; this.help = "sets the avatar of the bot"; this.arguments = ""; + this.aliases = JMusicBot.config.getAliases(this.name); this.guildOnly = false; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetgameCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetgameCmd.java index 443fbd6..7d778d6 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetgameCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetgameCmd.java @@ -16,6 +16,7 @@ package com.jagrosh.jmusicbot.commands.owner; import com.jagrosh.jdautilities.command.CommandEvent; +import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.commands.OwnerCommand; import net.dv8tion.jda.core.entities.Game; @@ -30,6 +31,7 @@ public class SetgameCmd extends OwnerCommand this.name = "setgame"; this.help = "sets the game the bot is playing"; this.arguments = "[action] [game]"; + this.aliases = JMusicBot.config.getAliases(this.name); this.guildOnly = false; this.children = new OwnerCommand[]{ new SetlistenCmd(), diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetnameCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetnameCmd.java index fab1c05..5a0b485 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetnameCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetnameCmd.java @@ -17,6 +17,7 @@ package com.jagrosh.jmusicbot.commands.owner; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; +import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.commands.OwnerCommand; import net.dv8tion.jda.core.exceptions.RateLimitedException; @@ -31,6 +32,7 @@ public class SetnameCmd extends OwnerCommand this.name = "setname"; this.help = "sets the name of the bot"; this.arguments = ""; + this.aliases = JMusicBot.config.getAliases(this.name); this.guildOnly = false; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetstatusCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetstatusCmd.java index 6089848..adb385b 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetstatusCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetstatusCmd.java @@ -16,6 +16,7 @@ package com.jagrosh.jmusicbot.commands.owner; import com.jagrosh.jdautilities.command.CommandEvent; +import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.commands.OwnerCommand; import net.dv8tion.jda.core.OnlineStatus; @@ -30,6 +31,7 @@ public class SetstatusCmd extends OwnerCommand this.name = "setstatus"; this.help = "sets the status the bot displays"; this.arguments = ""; + this.aliases = JMusicBot.config.getAliases(this.name); this.guildOnly = false; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/owner/ShutdownCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/owner/ShutdownCmd.java index b9ee0f3..fe0f87b 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/owner/ShutdownCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/owner/ShutdownCmd.java @@ -17,6 +17,7 @@ package com.jagrosh.jmusicbot.commands.owner; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; +import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.commands.OwnerCommand; /** @@ -32,6 +33,7 @@ public class ShutdownCmd extends OwnerCommand this.bot = bot; this.name = "shutdown"; this.help = "safely shuts down"; + this.aliases = JMusicBot.config.getAliases(this.name); this.guildOnly = false; } diff --git a/src/main/resources/reference.conf b/src/main/resources/reference.conf index c89a67d..36e4b82 100644 --- a/src/main/resources/reference.conf +++ b/src/main/resources/reference.conf @@ -123,6 +123,66 @@ updatealerts=true lyrics.default = "A-Z Lyrics" +// These settings allow you to configure custom aliases for all commands. +// Multiple aliases may be given, separated by spaces. +// +// Example 1: Giving command "play" the alias "p": +// alias.play = "p" +// +// Example 2: Giving command "search" the aliases "s" and "find": +// alias.search = "s find" + +// General commands + +alias.settings = "status" + + +// Music commands + +alias.lyrics = "" +alias.nowplaying = "np current" +alias.play = "" +alias.playlists = "pls" +alias.queue = "list" +alias.remove = "delete" +alias.scsearch = "" +alias.search = "ytsearch" +alias.shuffle = "" +alias.skip = "voteskip" + +// Admin commands + +alias.setdj = "" +alias.settc = "" +alias.setvc = "" + + +// DJ Commands + +alias.forceremove = "forcedelete modremove moddelete" +alias.forceskip = "modskip" +alias.movetrack = "move" +alias.pause = "" +alias.playnext = "" +alias.repeat = "" +alias.skipto = "jumpto" +alias.stop = "" +alias.volume = "v" + + +// Owner commands + +alias.autoplaylist = "" +alias.debug = "" +alias.eval = "" +alias.playlist = "" +alias.setavatar = "" +alias.setgame = "" +alias.setname = "" +alias.setstatus = "" +alias.shutdown = "" + + // If you set this to true, it will enable the eval command for the bot owner. This command // allows the bot owner to run arbitrary code from the bot's account. // From 94362d640b0358bc770c1e52ebd9980ddee45da1 Mon Sep 17 00:00:00 2001 From: MichailiK <39029839+MichailiK@users.noreply.github.com> Date: Fri, 25 Oct 2019 17:56:55 +0200 Subject: [PATCH 2/7] Change Example 2 --- src/main/resources/reference.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/reference.conf b/src/main/resources/reference.conf index 36e4b82..d2771e8 100644 --- a/src/main/resources/reference.conf +++ b/src/main/resources/reference.conf @@ -129,8 +129,8 @@ lyrics.default = "A-Z Lyrics" // Example 1: Giving command "play" the alias "p": // alias.play = "p" // -// Example 2: Giving command "search" the aliases "s" and "find": -// alias.search = "s find" +// Example 2: Giving command "search" the aliases "yts" and "find": +// alias.search = "yts find" // General commands From 4fcf86a5d68e049036263d0c55c6e52f7c715c1d Mon Sep 17 00:00:00 2001 From: MichailiK <39029839+MichailiK@users.noreply.github.com> Date: Fri, 25 Oct 2019 18:14:23 +0200 Subject: [PATCH 3/7] Fix alias of volume --- src/main/resources/reference.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/reference.conf b/src/main/resources/reference.conf index d2771e8..718c2ff 100644 --- a/src/main/resources/reference.conf +++ b/src/main/resources/reference.conf @@ -167,7 +167,7 @@ alias.playnext = "" alias.repeat = "" alias.skipto = "jumpto" alias.stop = "" -alias.volume = "v" +alias.volume = "vol" // Owner commands From f17058a3441f979951379e2be3da04345ebb19dd Mon Sep 17 00:00:00 2001 From: MichailiK <39029839+MichailiK@users.noreply.github.com> Date: Fri, 25 Oct 2019 19:25:05 +0200 Subject: [PATCH 4/7] Put aliases inside an "aliases"-block --- .../java/com/jagrosh/jmusicbot/BotConfig.java | 18 ++-- src/main/resources/reference.conf | 84 ++++++++++--------- 2 files changed, 55 insertions(+), 47 deletions(-) diff --git a/src/main/java/com/jagrosh/jmusicbot/BotConfig.java b/src/main/java/com/jagrosh/jmusicbot/BotConfig.java index 5cfb8e5..7aff8d0 100644 --- a/src/main/java/com/jagrosh/jmusicbot/BotConfig.java +++ b/src/main/java/com/jagrosh/jmusicbot/BotConfig.java @@ -46,8 +46,9 @@ public class BotConfig private long owner, maxSeconds; private OnlineStatus status; private Game game; + private Config aliases; + - private Config config; private boolean valid = false; public BotConfig(Prompt prompt) @@ -73,7 +74,7 @@ public class BotConfig // load in the config file, plus the default values //Config config = ConfigFactory.parseFile(path.toFile()).withFallback(ConfigFactory.load()); - config = ConfigFactory.load(); + Config config = ConfigFactory.load(); // set values token = config.getString("token"); @@ -95,6 +96,7 @@ public class BotConfig useEval = config.getBoolean("eval"); maxSeconds = config.getLong("maxtime"); playlistsFolder = config.getString("playlistsfolder"); + aliases = config.getConfig("aliases"); dbots = owner == 113156185389092864L; // we may need to write a new config file @@ -304,9 +306,13 @@ public class BotConfig public String[] getAliases(String command) { - String aliases = config.getString("alias."+command); - if(aliases == null || aliases.length() <= 0) - return new String[]{}; - return aliases.split(" "); + try + { + return aliases.getStringList(command).toArray(new String[0]); + } + catch(NullPointerException e) + { + return new String[0]; + } } } diff --git a/src/main/resources/reference.conf b/src/main/resources/reference.conf index 718c2ff..5067cee 100644 --- a/src/main/resources/reference.conf +++ b/src/main/resources/reference.conf @@ -124,64 +124,66 @@ lyrics.default = "A-Z Lyrics" // These settings allow you to configure custom aliases for all commands. -// Multiple aliases may be given, separated by spaces. +// Multiple aliases may be given, separated by commas. // // Example 1: Giving command "play" the alias "p": -// alias.play = "p" +// play = [ p ] // // Example 2: Giving command "search" the aliases "yts" and "find": -// alias.search = "yts find" +// search = [ yts, find ] -// General commands +aliases { -alias.settings = "status" + // General commands + + settings = [ status ] -// Music commands + // Music commands -alias.lyrics = "" -alias.nowplaying = "np current" -alias.play = "" -alias.playlists = "pls" -alias.queue = "list" -alias.remove = "delete" -alias.scsearch = "" -alias.search = "ytsearch" -alias.shuffle = "" -alias.skip = "voteskip" + lyrics = [] + nowplaying = [ np, current ] + play = [] + playlists = [ pls ] + queue = [ list ] + remove = [ delete ] + scsearch = [] + search = [ ytsearch ] + shuffle = [] + skip = [ voteskip ] -// Admin commands + // Admin commands -alias.setdj = "" -alias.settc = "" -alias.setvc = "" + setdj = [] + settc = [] + setvc = [] -// DJ Commands + // DJ Commands -alias.forceremove = "forcedelete modremove moddelete" -alias.forceskip = "modskip" -alias.movetrack = "move" -alias.pause = "" -alias.playnext = "" -alias.repeat = "" -alias.skipto = "jumpto" -alias.stop = "" -alias.volume = "vol" + forceremove = [ forcedelete, modremove, moddelete ] + forceskip = [ modskip ] + movetrack = [ move ] + pause = [] + playnext = [] + repeat = [] + skipto = [ jumpto ] + stop = [] + volume = [ vol ] -// Owner commands - -alias.autoplaylist = "" -alias.debug = "" -alias.eval = "" -alias.playlist = "" -alias.setavatar = "" -alias.setgame = "" -alias.setname = "" -alias.setstatus = "" -alias.shutdown = "" + // Owner commands + autoplaylist = [] + debug = [] + eval = [] + playlist = [] + setavatar = [] + setgame = [] + setname = [] + setstatus = [] + shutdown = [] +} // If you set this to true, it will enable the eval command for the bot owner. This command // allows the bot owner to run arbitrary code from the bot's account. From 0b4c6c9af151b0b607eb583f3cd8cf09178a90d6 Mon Sep 17 00:00:00 2001 From: MichailiK <39029839+MichailiK@users.noreply.github.com> Date: Fri, 25 Oct 2019 19:48:41 +0200 Subject: [PATCH 5/7] Use Bot#getConfig() instead of using a public static config & Add missing newline --- .../java/com/jagrosh/jmusicbot/JMusicBot.java | 19 +++++++++---------- .../jmusicbot/commands/admin/SetdjCmd.java | 6 +++--- .../jmusicbot/commands/admin/SettcCmd.java | 6 +++--- .../jmusicbot/commands/admin/SetvcCmd.java | 6 +++--- .../jmusicbot/commands/dj/ForceRemoveCmd.java | 3 +-- .../jmusicbot/commands/dj/ForceskipCmd.java | 3 +-- .../jmusicbot/commands/dj/MoveTrackCmd.java | 3 +-- .../jmusicbot/commands/dj/PauseCmd.java | 3 +-- .../jmusicbot/commands/dj/PlaynextCmd.java | 3 +-- .../jmusicbot/commands/dj/RepeatCmd.java | 3 +-- .../jmusicbot/commands/dj/SkiptoCmd.java | 3 +-- .../jmusicbot/commands/dj/StopCmd.java | 3 +-- .../jmusicbot/commands/dj/VolumeCmd.java | 3 +-- .../commands/general/SettingsCmd.java | 6 +++--- .../jmusicbot/commands/music/LyricsCmd.java | 3 +-- .../commands/music/NowplayingCmd.java | 3 +-- .../jmusicbot/commands/music/PlayCmd.java | 3 +-- .../commands/music/PlaylistsCmd.java | 3 +-- .../jmusicbot/commands/music/QueueCmd.java | 2 +- .../jmusicbot/commands/music/RemoveCmd.java | 3 +-- .../jmusicbot/commands/music/SCSearchCmd.java | 2 +- .../jmusicbot/commands/music/SearchCmd.java | 3 +-- .../jmusicbot/commands/music/ShuffleCmd.java | 3 +-- .../jmusicbot/commands/music/SkipCmd.java | 3 +-- .../commands/owner/AutoplaylistCmd.java | 3 +-- .../jmusicbot/commands/owner/DebugCmd.java | 3 +-- .../jmusicbot/commands/owner/EvalCmd.java | 3 +-- .../jmusicbot/commands/owner/PlaylistCmd.java | 4 +--- .../commands/owner/SetavatarCmd.java | 6 +++--- .../jmusicbot/commands/owner/SetgameCmd.java | 6 +++--- .../jmusicbot/commands/owner/SetnameCmd.java | 5 ++--- .../commands/owner/SetstatusCmd.java | 6 +++--- .../jmusicbot/commands/owner/ShutdownCmd.java | 3 +-- src/main/resources/reference.conf | 1 + 34 files changed, 57 insertions(+), 81 deletions(-) diff --git a/src/main/java/com/jagrosh/jmusicbot/JMusicBot.java b/src/main/java/com/jagrosh/jmusicbot/JMusicBot.java index 6be2c93..81028dc 100644 --- a/src/main/java/com/jagrosh/jmusicbot/JMusicBot.java +++ b/src/main/java/com/jagrosh/jmusicbot/JMusicBot.java @@ -46,7 +46,6 @@ public class JMusicBot public final static Permission[] RECOMMENDED_PERMS = new Permission[]{Permission.MESSAGE_READ, Permission.MESSAGE_WRITE, Permission.MESSAGE_HISTORY, Permission.MESSAGE_ADD_REACTION, Permission.MESSAGE_EMBED_LINKS, Permission.MESSAGE_ATTACH_FILES, Permission.MESSAGE_MANAGE, Permission.MESSAGE_EXT_EMOJI, Permission.MANAGE_CHANNEL, Permission.VOICE_CONNECT, Permission.VOICE_SPEAK, Permission.NICKNAME_CHANGE}; - public static BotConfig config; /** * @param args the command line arguments */ @@ -72,7 +71,7 @@ public class JMusicBot String version = OtherUtil.checkVersion(prompt); // load config - config = new BotConfig(prompt); + BotConfig config = new BotConfig(prompt); config.load(); if(!config.isValid()) return; @@ -100,7 +99,7 @@ public class JMusicBot .setGuildSettingsManager(settings) .addCommands(aboutCommand, new PingCommand(), - new SettingsCmd(), + new SettingsCmd(bot), new LyricsCmd(bot), new NowplayingCmd(bot), @@ -123,17 +122,17 @@ public class JMusicBot new StopCmd(bot), new VolumeCmd(bot), - new SetdjCmd(), - new SettcCmd(), - new SetvcCmd(), + new SetdjCmd(bot), + new SettcCmd(bot), + new SetvcCmd(bot), new AutoplaylistCmd(bot), new DebugCmd(bot), new PlaylistCmd(bot), - new SetavatarCmd(), - new SetgameCmd(), - new SetnameCmd(), - new SetstatusCmd(), + new SetavatarCmd(bot), + new SetgameCmd(bot), + new SetnameCmd(bot), + new SetstatusCmd(bot), new ShutdownCmd(bot) ); if(config.useEval()) diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetdjCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetdjCmd.java index 3423461..e34df48 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetdjCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetdjCmd.java @@ -18,7 +18,7 @@ package com.jagrosh.jmusicbot.commands.admin; import java.util.List; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jdautilities.commons.utils.FinderUtil; -import com.jagrosh.jmusicbot.JMusicBot; +import com.jagrosh.jmusicbot.Bot; import com.jagrosh.jmusicbot.commands.AdminCommand; import com.jagrosh.jmusicbot.settings.Settings; import com.jagrosh.jmusicbot.utils.FormatUtil; @@ -30,12 +30,12 @@ import net.dv8tion.jda.core.entities.Role; */ public class SetdjCmd extends AdminCommand { - public SetdjCmd() + public SetdjCmd(Bot bot) { this.name = "setdj"; this.help = "sets the DJ role for certain music commands"; this.arguments = ""; - this.aliases = JMusicBot.config.getAliases(this.name); + this.aliases = bot.getConfig().getAliases(this.name); } @Override diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/admin/SettcCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/admin/SettcCmd.java index 3d750be..b4b3d46 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/admin/SettcCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/admin/SettcCmd.java @@ -18,7 +18,7 @@ package com.jagrosh.jmusicbot.commands.admin; import java.util.List; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jdautilities.commons.utils.FinderUtil; -import com.jagrosh.jmusicbot.JMusicBot; +import com.jagrosh.jmusicbot.Bot; import com.jagrosh.jmusicbot.commands.AdminCommand; import com.jagrosh.jmusicbot.settings.Settings; import com.jagrosh.jmusicbot.utils.FormatUtil; @@ -30,12 +30,12 @@ import net.dv8tion.jda.core.entities.TextChannel; */ public class SettcCmd extends AdminCommand { - public SettcCmd() + public SettcCmd(Bot bot) { this.name = "settc"; this.help = "sets the text channel for music commands"; this.arguments = ""; - this.aliases = JMusicBot.config.getAliases(this.name); + this.aliases = bot.getConfig().getAliases(this.name); } @Override diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetvcCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetvcCmd.java index a106438..6248463 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetvcCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/admin/SetvcCmd.java @@ -18,7 +18,7 @@ package com.jagrosh.jmusicbot.commands.admin; import java.util.List; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jdautilities.commons.utils.FinderUtil; -import com.jagrosh.jmusicbot.JMusicBot; +import com.jagrosh.jmusicbot.Bot; import com.jagrosh.jmusicbot.commands.AdminCommand; import com.jagrosh.jmusicbot.settings.Settings; import com.jagrosh.jmusicbot.utils.FormatUtil; @@ -30,12 +30,12 @@ import net.dv8tion.jda.core.entities.VoiceChannel; */ public class SetvcCmd extends AdminCommand { - public SetvcCmd() + public SetvcCmd(Bot bot) { this.name = "setvc"; this.help = "sets the voice channel for playing music"; this.arguments = ""; - this.aliases = JMusicBot.config.getAliases(this.name); + this.aliases = bot.getConfig().getAliases(this.name); } @Override diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/dj/ForceRemoveCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/dj/ForceRemoveCmd.java index 5aa1c1c..0cca3e7 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/dj/ForceRemoveCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/dj/ForceRemoveCmd.java @@ -19,7 +19,6 @@ import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jdautilities.commons.utils.FinderUtil; import com.jagrosh.jdautilities.menu.OrderedMenu; import com.jagrosh.jmusicbot.Bot; -import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.audio.AudioHandler; import com.jagrosh.jmusicbot.commands.DJCommand; import net.dv8tion.jda.core.Permission; @@ -41,7 +40,7 @@ public class ForceRemoveCmd extends DJCommand this.name = "forceremove"; this.help = "removes all entries by a user from the queue"; this.arguments = ""; - this.aliases = JMusicBot.config.getAliases(this.name); + this.aliases = bot.getConfig().getAliases(this.name); this.beListening = false; this.bePlaying = true; this.botPermissions = new Permission[]{Permission.MESSAGE_EMBED_LINKS}; diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/dj/ForceskipCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/dj/ForceskipCmd.java index a2d79dc..053cc5c 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/dj/ForceskipCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/dj/ForceskipCmd.java @@ -17,7 +17,6 @@ package com.jagrosh.jmusicbot.commands.dj; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; -import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.audio.AudioHandler; import com.jagrosh.jmusicbot.commands.DJCommand; import net.dv8tion.jda.core.entities.User; @@ -33,7 +32,7 @@ public class ForceskipCmd extends DJCommand super(bot); this.name = "forceskip"; this.help = "skips the current song"; - this.aliases = JMusicBot.config.getAliases(this.name); + this.aliases = bot.getConfig().getAliases(this.name); this.bePlaying = true; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/dj/MoveTrackCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/dj/MoveTrackCmd.java index b4f0945..7c652f9 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/dj/MoveTrackCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/dj/MoveTrackCmd.java @@ -3,7 +3,6 @@ package com.jagrosh.jmusicbot.commands.dj; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; -import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.audio.AudioHandler; import com.jagrosh.jmusicbot.audio.QueuedTrack; import com.jagrosh.jmusicbot.commands.DJCommand; @@ -21,7 +20,7 @@ public class MoveTrackCmd extends DJCommand this.name = "movetrack"; this.help = "move a track in the current queue to a different position"; this.arguments = " "; - this.aliases = JMusicBot.config.getAliases(this.name); + this.aliases = bot.getConfig().getAliases(this.name); this.bePlaying = true; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/dj/PauseCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/dj/PauseCmd.java index c374fb2..9a923f0 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/dj/PauseCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/dj/PauseCmd.java @@ -17,7 +17,6 @@ package com.jagrosh.jmusicbot.commands.dj; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; -import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.audio.AudioHandler; import com.jagrosh.jmusicbot.commands.DJCommand; @@ -32,7 +31,7 @@ public class PauseCmd extends DJCommand super(bot); this.name = "pause"; this.help = "pauses the current song"; - this.aliases = JMusicBot.config.getAliases(this.name); + this.aliases = bot.getConfig().getAliases(this.name); this.bePlaying = true; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/dj/PlaynextCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/dj/PlaynextCmd.java index 9c2b277..b9f2c88 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/dj/PlaynextCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/dj/PlaynextCmd.java @@ -17,7 +17,6 @@ package com.jagrosh.jmusicbot.commands.dj; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; -import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.audio.AudioHandler; import com.jagrosh.jmusicbot.audio.QueuedTrack; import com.jagrosh.jmusicbot.commands.DJCommand; @@ -43,7 +42,7 @@ public class PlaynextCmd extends DJCommand this.name = "playnext"; this.arguments = ""; this.help = "plays a single song next"; - this.aliases = JMusicBot.config.getAliases(this.name); + this.aliases = bot.getConfig().getAliases(this.name); this.beListening = true; this.bePlaying = false; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/dj/RepeatCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/dj/RepeatCmd.java index 183d7da..bba099b 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/dj/RepeatCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/dj/RepeatCmd.java @@ -17,7 +17,6 @@ package com.jagrosh.jmusicbot.commands.dj; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; -import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.commands.DJCommand; import com.jagrosh.jmusicbot.settings.Settings; @@ -33,7 +32,7 @@ public class RepeatCmd extends DJCommand this.name = "repeat"; this.help = "re-adds music to the queue when finished"; this.arguments = "[on|off]"; - this.aliases = JMusicBot.config.getAliases(this.name); + this.aliases = bot.getConfig().getAliases(this.name); this.guildOnly = true; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/dj/SkiptoCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/dj/SkiptoCmd.java index 9eb2ce1..e7fffb5 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/dj/SkiptoCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/dj/SkiptoCmd.java @@ -17,7 +17,6 @@ package com.jagrosh.jmusicbot.commands.dj; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; -import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.audio.AudioHandler; import com.jagrosh.jmusicbot.commands.DJCommand; @@ -33,7 +32,7 @@ public class SkiptoCmd extends DJCommand this.name = "skipto"; this.help = "skips to the specified song"; this.arguments = ""; - this.aliases = JMusicBot.config.getAliases(this.name); + this.aliases = bot.getConfig().getAliases(this.name); this.bePlaying = true; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/dj/StopCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/dj/StopCmd.java index b8d6700..8caa67c 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/dj/StopCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/dj/StopCmd.java @@ -17,7 +17,6 @@ package com.jagrosh.jmusicbot.commands.dj; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; -import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.audio.AudioHandler; import com.jagrosh.jmusicbot.commands.DJCommand; @@ -32,7 +31,7 @@ public class StopCmd extends DJCommand super(bot); this.name = "stop"; this.help = "stops the current song and clears the queue"; - this.aliases = JMusicBot.config.getAliases(this.name); + this.aliases = bot.getConfig().getAliases(this.name); this.bePlaying = false; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/dj/VolumeCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/dj/VolumeCmd.java index c45e741..0b50c64 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/dj/VolumeCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/dj/VolumeCmd.java @@ -17,7 +17,6 @@ package com.jagrosh.jmusicbot.commands.dj; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; -import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.audio.AudioHandler; import com.jagrosh.jmusicbot.commands.DJCommand; import com.jagrosh.jmusicbot.settings.Settings; @@ -33,7 +32,7 @@ public class VolumeCmd extends DJCommand { super(bot); this.name = "volume"; - this.aliases = JMusicBot.config.getAliases(this.name); + this.aliases = bot.getConfig().getAliases(this.name); this.help = "sets or shows volume"; this.arguments = "[0-150]"; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/general/SettingsCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/general/SettingsCmd.java index 899e544..1ea8f3b 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/general/SettingsCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/general/SettingsCmd.java @@ -17,7 +17,7 @@ package com.jagrosh.jmusicbot.commands.general; import com.jagrosh.jdautilities.command.Command; import com.jagrosh.jdautilities.command.CommandEvent; -import com.jagrosh.jmusicbot.JMusicBot; +import com.jagrosh.jmusicbot.Bot; import com.jagrosh.jmusicbot.settings.Settings; import net.dv8tion.jda.core.EmbedBuilder; import net.dv8tion.jda.core.MessageBuilder; @@ -33,11 +33,11 @@ public class SettingsCmd extends Command { private final static String EMOJI = "\uD83C\uDFA7"; // 🎧 - public SettingsCmd() + public SettingsCmd(Bot bot) { this.name = "settings"; this.help = "shows the bots settings"; - this.aliases = JMusicBot.config.getAliases(this.name); + this.aliases = bot.getConfig().getAliases(this.name); this.guildOnly = true; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/music/LyricsCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/music/LyricsCmd.java index 89feb43..27fc9f4 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/music/LyricsCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/music/LyricsCmd.java @@ -19,7 +19,6 @@ import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jlyrics.Lyrics; import com.jagrosh.jlyrics.LyricsClient; import com.jagrosh.jmusicbot.Bot; -import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.audio.AudioHandler; import com.jagrosh.jmusicbot.commands.MusicCommand; import java.util.concurrent.ExecutionException; @@ -40,7 +39,7 @@ public class LyricsCmd extends MusicCommand this.name = "lyrics"; this.arguments = "[song name]"; this.help = "shows the lyrics to the currently-playing song"; - this.aliases = JMusicBot.config.getAliases(this.name); + this.aliases = bot.getConfig().getAliases(this.name); this.botPermissions = new Permission[]{Permission.MESSAGE_EMBED_LINKS}; this.bePlaying = true; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/music/NowplayingCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/music/NowplayingCmd.java index 6350369..b263d25 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/music/NowplayingCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/music/NowplayingCmd.java @@ -17,7 +17,6 @@ package com.jagrosh.jmusicbot.commands.music; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; -import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.audio.AudioHandler; import com.jagrosh.jmusicbot.commands.MusicCommand; import net.dv8tion.jda.core.Permission; @@ -34,7 +33,7 @@ public class NowplayingCmd extends MusicCommand super(bot); this.name = "nowplaying"; this.help = "shows the song that is currently playing"; - this.aliases = JMusicBot.config.getAliases(this.name); + this.aliases = bot.getConfig().getAliases(this.name); this.botPermissions = new Permission[]{Permission.MESSAGE_EMBED_LINKS}; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/music/PlayCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/music/PlayCmd.java index ccf711a..7119b5c 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/music/PlayCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/music/PlayCmd.java @@ -15,7 +15,6 @@ */ package com.jagrosh.jmusicbot.commands.music; -import com.jagrosh.jmusicbot.JMusicBot; import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler; import com.sedmelluq.discord.lavaplayer.tools.FriendlyException; import com.sedmelluq.discord.lavaplayer.tools.FriendlyException.Severity; @@ -54,7 +53,7 @@ public class PlayCmd extends MusicCommand this.name = "play"; this.arguments = ""; this.help = "plays the provided song"; - this.aliases = JMusicBot.config.getAliases(this.name); + this.aliases = bot.getConfig().getAliases(this.name); this.beListening = true; this.bePlaying = false; this.children = new Command[]{new PlaylistCmd(bot)}; diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/music/PlaylistsCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/music/PlaylistsCmd.java index 04cc071..858a764 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/music/PlaylistsCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/music/PlaylistsCmd.java @@ -18,7 +18,6 @@ package com.jagrosh.jmusicbot.commands.music; import java.util.List; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; -import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.commands.MusicCommand; /** @@ -32,7 +31,7 @@ public class PlaylistsCmd extends MusicCommand super(bot); this.name = "playlists"; this.help = "shows the available playlists"; - this.aliases = JMusicBot.config.getAliases(this.name); + this.aliases = bot.getConfig().getAliases(this.name); this.guildOnly = true; this.beListening = false; this.beListening = false; diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/music/QueueCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/music/QueueCmd.java index a503fc1..d36e5b9 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/music/QueueCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/music/QueueCmd.java @@ -47,7 +47,7 @@ public class QueueCmd extends MusicCommand this.name = "queue"; this.help = "shows the current queue"; this.arguments = "[pagenum]"; - this.aliases = JMusicBot.config.getAliases(this.name); + this.aliases = bot.getConfig().getAliases(this.name); this.bePlaying = true; this.botPermissions = new Permission[]{Permission.MESSAGE_ADD_REACTION,Permission.MESSAGE_EMBED_LINKS}; builder = new Paginator.Builder() diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/music/RemoveCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/music/RemoveCmd.java index d6ddfa0..05aa99a 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/music/RemoveCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/music/RemoveCmd.java @@ -17,7 +17,6 @@ package com.jagrosh.jmusicbot.commands.music; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; -import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.audio.AudioHandler; import com.jagrosh.jmusicbot.audio.QueuedTrack; import com.jagrosh.jmusicbot.commands.MusicCommand; @@ -37,7 +36,7 @@ public class RemoveCmd extends MusicCommand this.name = "remove"; this.help = "removes a song from the queue"; this.arguments = ""; - this.aliases = JMusicBot.config.getAliases(this.name); + this.aliases = bot.getConfig().getAliases(this.name); this.beListening = true; this.bePlaying = true; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/music/SCSearchCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/music/SCSearchCmd.java index a908e0d..b51a9f0 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/music/SCSearchCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/music/SCSearchCmd.java @@ -30,6 +30,6 @@ public class SCSearchCmd extends SearchCmd this.searchPrefix = "scsearch:"; this.name = "scsearch"; this.help = "searches Soundcloud for a provided query"; - this.aliases = JMusicBot.config.getAliases(this.name); + this.aliases = bot.getConfig().getAliases(this.name); } } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/music/SearchCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/music/SearchCmd.java index 7d413bb..5cac64f 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/music/SearchCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/music/SearchCmd.java @@ -15,7 +15,6 @@ */ package com.jagrosh.jmusicbot.commands.music; -import com.jagrosh.jmusicbot.JMusicBot; import com.sedmelluq.discord.lavaplayer.player.AudioLoadResultHandler; import com.sedmelluq.discord.lavaplayer.tools.FriendlyException; import com.sedmelluq.discord.lavaplayer.tools.FriendlyException.Severity; @@ -47,7 +46,7 @@ public class SearchCmd extends MusicCommand super(bot); this.searchingEmoji = bot.getConfig().getSearching(); this.name = "search"; - this.aliases = JMusicBot.config.getAliases(this.name); + this.aliases = bot.getConfig().getAliases(this.name); this.arguments = ""; this.help = "searches Youtube for a provided query"; this.beListening = true; diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/music/ShuffleCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/music/ShuffleCmd.java index 68421b7..c151f4d 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/music/ShuffleCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/music/ShuffleCmd.java @@ -17,7 +17,6 @@ package com.jagrosh.jmusicbot.commands.music; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; -import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.audio.AudioHandler; import com.jagrosh.jmusicbot.commands.MusicCommand; @@ -32,7 +31,7 @@ public class ShuffleCmd extends MusicCommand super(bot); this.name = "shuffle"; this.help = "shuffles songs you have added"; - this.aliases = JMusicBot.config.getAliases(this.name); + this.aliases = bot.getConfig().getAliases(this.name); this.beListening = true; this.bePlaying = true; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/music/SkipCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/music/SkipCmd.java index 9604e1c..97fc430 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/music/SkipCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/music/SkipCmd.java @@ -17,7 +17,6 @@ package com.jagrosh.jmusicbot.commands.music; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; -import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.audio.AudioHandler; import com.jagrosh.jmusicbot.commands.MusicCommand; import net.dv8tion.jda.core.entities.User; @@ -33,7 +32,7 @@ public class SkipCmd extends MusicCommand super(bot); this.name = "skip"; this.help = "votes to skip the current song"; - this.aliases = JMusicBot.config.getAliases(this.name); + this.aliases = bot.getConfig().getAliases(this.name); this.beListening = true; this.bePlaying = true; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/owner/AutoplaylistCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/owner/AutoplaylistCmd.java index a908bba..107340d 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/owner/AutoplaylistCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/owner/AutoplaylistCmd.java @@ -17,7 +17,6 @@ package com.jagrosh.jmusicbot.commands.owner; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; -import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.commands.OwnerCommand; import com.jagrosh.jmusicbot.settings.Settings; @@ -36,7 +35,7 @@ public class AutoplaylistCmd extends OwnerCommand this.name = "autoplaylist"; this.arguments = ""; this.help = "sets the default playlist for the server"; - this.aliases = JMusicBot.config.getAliases(this.name); + this.aliases = bot.getConfig().getAliases(this.name); } @Override diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/owner/DebugCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/owner/DebugCmd.java index 8b29ce3..0c2ee1b 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/owner/DebugCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/owner/DebugCmd.java @@ -18,7 +18,6 @@ package com.jagrosh.jmusicbot.commands.owner; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jdautilities.commons.JDAUtilitiesInfo; import com.jagrosh.jmusicbot.Bot; -import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.commands.OwnerCommand; import com.jagrosh.jmusicbot.utils.OtherUtil; import com.sedmelluq.discord.lavaplayer.tools.PlayerLibrary; @@ -42,7 +41,7 @@ public class DebugCmd extends OwnerCommand this.bot = bot; this.name = "debug"; this.help = "shows debug info"; - this.aliases = JMusicBot.config.getAliases(this.name); + this.aliases = bot.getConfig().getAliases(this.name); this.guildOnly = false; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/owner/EvalCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/owner/EvalCmd.java index 82e6d94..4c50d7d 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/owner/EvalCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/owner/EvalCmd.java @@ -19,7 +19,6 @@ import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; -import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.commands.OwnerCommand; /** @@ -35,7 +34,7 @@ public class EvalCmd extends OwnerCommand this.bot = bot; this.name = "eval"; this.help = "evaluates nashorn code"; - this.aliases = JMusicBot.config.getAliases(this.name); + this.aliases = bot.getConfig().getAliases(this.name); this.guildOnly = false; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/owner/PlaylistCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/owner/PlaylistCmd.java index 5167e5c..0caf397 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/owner/PlaylistCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/owner/PlaylistCmd.java @@ -20,9 +20,7 @@ import java.util.List; import com.jagrosh.jdautilities.command.Command; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; -import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.commands.OwnerCommand; -import com.jagrosh.jmusicbot.commands.owner.AutoplaylistCmd; import com.jagrosh.jmusicbot.playlist.PlaylistLoader.Playlist; /** @@ -39,7 +37,7 @@ public class PlaylistCmd extends OwnerCommand this.name = "playlist"; this.arguments = ""; this.help = "playlist management"; - this.aliases = JMusicBot.config.getAliases(this.name); + this.aliases = bot.getConfig().getAliases(this.name); this.children = new OwnerCommand[]{ new ListCmd(), new AppendlistCmd(), diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetavatarCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetavatarCmd.java index c0b877a..7d17e28 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetavatarCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetavatarCmd.java @@ -18,7 +18,7 @@ package com.jagrosh.jmusicbot.commands.owner; import java.io.IOException; import java.io.InputStream; import com.jagrosh.jdautilities.command.CommandEvent; -import com.jagrosh.jmusicbot.JMusicBot; +import com.jagrosh.jmusicbot.Bot; import com.jagrosh.jmusicbot.commands.OwnerCommand; import com.jagrosh.jmusicbot.utils.OtherUtil; import net.dv8tion.jda.core.entities.Icon; @@ -29,12 +29,12 @@ import net.dv8tion.jda.core.entities.Icon; */ public class SetavatarCmd extends OwnerCommand { - public SetavatarCmd() + public SetavatarCmd(Bot bot) { this.name = "setavatar"; this.help = "sets the avatar of the bot"; this.arguments = ""; - this.aliases = JMusicBot.config.getAliases(this.name); + this.aliases = bot.getConfig().getAliases(this.name); this.guildOnly = false; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetgameCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetgameCmd.java index 7d778d6..27cf072 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetgameCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetgameCmd.java @@ -16,7 +16,7 @@ package com.jagrosh.jmusicbot.commands.owner; import com.jagrosh.jdautilities.command.CommandEvent; -import com.jagrosh.jmusicbot.JMusicBot; +import com.jagrosh.jmusicbot.Bot; import com.jagrosh.jmusicbot.commands.OwnerCommand; import net.dv8tion.jda.core.entities.Game; @@ -26,12 +26,12 @@ import net.dv8tion.jda.core.entities.Game; */ public class SetgameCmd extends OwnerCommand { - public SetgameCmd() + public SetgameCmd(Bot bot) { this.name = "setgame"; this.help = "sets the game the bot is playing"; this.arguments = "[action] [game]"; - this.aliases = JMusicBot.config.getAliases(this.name); + this.aliases = bot.getConfig().getAliases(this.name); this.guildOnly = false; this.children = new OwnerCommand[]{ new SetlistenCmd(), diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetnameCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetnameCmd.java index 5a0b485..4bc90ab 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetnameCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetnameCmd.java @@ -17,7 +17,6 @@ package com.jagrosh.jmusicbot.commands.owner; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; -import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.commands.OwnerCommand; import net.dv8tion.jda.core.exceptions.RateLimitedException; @@ -27,12 +26,12 @@ import net.dv8tion.jda.core.exceptions.RateLimitedException; */ public class SetnameCmd extends OwnerCommand { - public SetnameCmd() + public SetnameCmd(Bot bot) { this.name = "setname"; this.help = "sets the name of the bot"; this.arguments = ""; - this.aliases = JMusicBot.config.getAliases(this.name); + this.aliases = bot.getConfig().getAliases(this.name); this.guildOnly = false; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetstatusCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetstatusCmd.java index adb385b..90d8c3e 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetstatusCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/owner/SetstatusCmd.java @@ -16,7 +16,7 @@ package com.jagrosh.jmusicbot.commands.owner; import com.jagrosh.jdautilities.command.CommandEvent; -import com.jagrosh.jmusicbot.JMusicBot; +import com.jagrosh.jmusicbot.Bot; import com.jagrosh.jmusicbot.commands.OwnerCommand; import net.dv8tion.jda.core.OnlineStatus; @@ -26,12 +26,12 @@ import net.dv8tion.jda.core.OnlineStatus; */ public class SetstatusCmd extends OwnerCommand { - public SetstatusCmd() + public SetstatusCmd(Bot bot) { this.name = "setstatus"; this.help = "sets the status the bot displays"; this.arguments = ""; - this.aliases = JMusicBot.config.getAliases(this.name); + this.aliases = bot.getConfig().getAliases(this.name); this.guildOnly = false; } diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/owner/ShutdownCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/owner/ShutdownCmd.java index fe0f87b..2a59cec 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/owner/ShutdownCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/owner/ShutdownCmd.java @@ -17,7 +17,6 @@ package com.jagrosh.jmusicbot.commands.owner; import com.jagrosh.jdautilities.command.CommandEvent; import com.jagrosh.jmusicbot.Bot; -import com.jagrosh.jmusicbot.JMusicBot; import com.jagrosh.jmusicbot.commands.OwnerCommand; /** @@ -33,7 +32,7 @@ public class ShutdownCmd extends OwnerCommand this.bot = bot; this.name = "shutdown"; this.help = "safely shuts down"; - this.aliases = JMusicBot.config.getAliases(this.name); + this.aliases = bot.getConfig().getAliases(this.name); this.guildOnly = false; } diff --git a/src/main/resources/reference.conf b/src/main/resources/reference.conf index 5067cee..05dabe7 100644 --- a/src/main/resources/reference.conf +++ b/src/main/resources/reference.conf @@ -152,6 +152,7 @@ aliases { shuffle = [] skip = [ voteskip ] + // Admin commands setdj = [] From f4a937cc6b52c00cec1b60be5810a01ce46b2d25 Mon Sep 17 00:00:00 2001 From: MichailiK <39029839+MichailiK@users.noreply.github.com> Date: Fri, 25 Oct 2019 20:03:45 +0200 Subject: [PATCH 6/7] Remove unused import from SCSearchCmd --- .../java/com/jagrosh/jmusicbot/commands/music/SCSearchCmd.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/jagrosh/jmusicbot/commands/music/SCSearchCmd.java b/src/main/java/com/jagrosh/jmusicbot/commands/music/SCSearchCmd.java index b51a9f0..63e4c67 100644 --- a/src/main/java/com/jagrosh/jmusicbot/commands/music/SCSearchCmd.java +++ b/src/main/java/com/jagrosh/jmusicbot/commands/music/SCSearchCmd.java @@ -16,7 +16,6 @@ package com.jagrosh.jmusicbot.commands.music; import com.jagrosh.jmusicbot.Bot; -import com.jagrosh.jmusicbot.JMusicBot; /** * From 179f447a709ac3f1ac64d706a222c81a5c5c6bad Mon Sep 17 00:00:00 2001 From: MichailiK <39029839+MichailiK@users.noreply.github.com> Date: Sat, 26 Oct 2019 09:39:56 +0200 Subject: [PATCH 7/7] Catch ConfigException.Missing in BotConfig#getAliases(string) --- src/main/java/com/jagrosh/jmusicbot/BotConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/jagrosh/jmusicbot/BotConfig.java b/src/main/java/com/jagrosh/jmusicbot/BotConfig.java index 7aff8d0..098cc85 100644 --- a/src/main/java/com/jagrosh/jmusicbot/BotConfig.java +++ b/src/main/java/com/jagrosh/jmusicbot/BotConfig.java @@ -310,7 +310,7 @@ public class BotConfig { return aliases.getStringList(command).toArray(new String[0]); } - catch(NullPointerException e) + catch(NullPointerException | ConfigException.Missing e) { return new String[0]; }