From 9cb464534a2a2d4147f490cf4c36c3ccf33691b6 Mon Sep 17 00:00:00 2001 From: bombies Date: Tue, 28 Dec 2021 23:46:25 -0500 Subject: [PATCH] Update requester display for now playing message --- dependency-reduced-pom.xml | 2 +- .../java/main/audiohandlers/TrackScheduler.java | 2 +- src/main/java/main/commands/CooldownManager.java | 2 +- .../commands/dev/MongoMigrationCommand.java | 5 +++++ .../dedicatechannel/DedicatedChannelEvents.java | 8 ++++++++ src/main/java/main/main/Listener.java | 15 +++++++++++++++ 6 files changed, 31 insertions(+), 3 deletions(-) diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml index 3882cfc6..a5dc9007 100644 --- a/dependency-reduced-pom.xml +++ b/dependency-reduced-pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.bombies Robertify-Bot - 1.6.2 + 2.0.0 diff --git a/src/main/java/main/audiohandlers/TrackScheduler.java b/src/main/java/main/audiohandlers/TrackScheduler.java index f20fd304..831db0f2 100644 --- a/src/main/java/main/audiohandlers/TrackScheduler.java +++ b/src/main/java/main/audiohandlers/TrackScheduler.java @@ -80,7 +80,7 @@ public void onTrackStart(AudioPlayer player, AudioTrack track) { TextChannel announcementChannel = Robertify.api.getTextChannelById(new GuildConfig().getAnnouncementChannelID(this.guild.getIdLong())); EmbedBuilder eb = EmbedUtils.embedMessage("Now Playing: `" + track.getInfo().title + "` by `"+track.getInfo().author+"`" + ((new TogglesConfig().getToggle(guild, Toggles.SHOW_REQUESTER) && requester != null) ? - " [" + requester.getAsMention() + "]" + "\n\n~ Requested by " + requester.getAsMention() : "" )); diff --git a/src/main/java/main/commands/CooldownManager.java b/src/main/java/main/commands/CooldownManager.java index cda35896..fe08a041 100644 --- a/src/main/java/main/commands/CooldownManager.java +++ b/src/main/java/main/commands/CooldownManager.java @@ -6,7 +6,7 @@ public class CooldownManager { private HashMap cooldowns = new HashMap<>(); - public static final long DEFAULT_COOLDOWN = 1L; + public static final long DEFAULT_COOLDOWN = 0L; public void setCooldown(User u, long time) { if (time == 0) diff --git a/src/main/java/main/commands/commands/dev/MongoMigrationCommand.java b/src/main/java/main/commands/commands/dev/MongoMigrationCommand.java index be285ea3..e9c752a3 100644 --- a/src/main/java/main/commands/commands/dev/MongoMigrationCommand.java +++ b/src/main/java/main/commands/commands/dev/MongoMigrationCommand.java @@ -1,6 +1,7 @@ package main.commands.commands.dev; import com.jagrosh.jdautilities.commons.waiter.EventWaiter; +import lombok.Getter; import main.commands.CommandContext; import main.commands.CommandManager; import main.commands.IDevCommand; @@ -39,6 +40,8 @@ public class MongoMigrationCommand implements IDevCommand { private final Logger logger = LoggerFactory.getLogger(MongoMigrationCommand.class); private final String migrationPrefix = "[Mongo Migration]"; + @Getter + private static boolean isMigrating = false; @Override public void handle(CommandContext ctx) throws ScriptException { @@ -73,6 +76,7 @@ public void handle(CommandContext ctx) throws ScriptException { } private void migrateAll() { + isMigrating = true; logger.info(""" ------------------------------------------------------ @@ -271,6 +275,7 @@ private void migrateAll() { {} Data migration completed! ------------------------------------------------------""", migrationPrefix); + isMigrating = false; } private void migrateDevelopers() { diff --git a/src/main/java/main/commands/commands/management/dedicatechannel/DedicatedChannelEvents.java b/src/main/java/main/commands/commands/management/dedicatechannel/DedicatedChannelEvents.java index 25e549bd..e2b92b8c 100644 --- a/src/main/java/main/commands/commands/management/dedicatechannel/DedicatedChannelEvents.java +++ b/src/main/java/main/commands/commands/management/dedicatechannel/DedicatedChannelEvents.java @@ -5,6 +5,7 @@ import main.commands.CommandContext; import main.commands.ICommand; import main.commands.commands.audio.*; +import main.commands.commands.dev.MongoMigrationCommand; import main.commands.commands.management.permissions.Permission; import main.utils.json.dedicatedchannel.DedicatedChannelConfig; import main.utils.json.guildconfig.GuildConfig; @@ -56,6 +57,13 @@ public void onGuildMessageReceived(@NotNull GuildMessageReceivedEvent event) { final User user = event.getAuthor(); if (!user.isBot()) { + if (MongoMigrationCommand.isMigrating()) { + event.getMessage().replyEmbeds(EmbedUtils.embedMessage("I am migrating databases at the moment!" + + " You are not allowed to use this feature.") + .build()).queue(); + return; + } + if (!memberVoiceState.inVoiceChannel()) { event.getMessage().reply(user.getAsMention()).setEmbeds(EmbedUtils.embedMessage("You must be in a voice channel to use this command") .build()) diff --git a/src/main/java/main/main/Listener.java b/src/main/java/main/main/Listener.java index a2f1822e..1b64e8a1 100644 --- a/src/main/java/main/main/Listener.java +++ b/src/main/java/main/main/Listener.java @@ -4,6 +4,7 @@ import lombok.SneakyThrows; import main.commands.CommandManager; import main.commands.commands.audio.slashcommands.*; +import main.commands.commands.dev.MongoMigrationCommand; import main.commands.commands.management.BanCommand; import main.commands.commands.management.SetChannelCommand; import main.commands.commands.management.UnbanCommand; @@ -115,6 +116,13 @@ public void onGuildMessageReceived(@NotNull GuildMessageReceivedEvent event) { .queue(); } else { try { + if (MongoMigrationCommand.isMigrating()) { + event.getMessage().replyEmbeds(EmbedUtils.embedMessage("I am migrating databases at the moment!" + + " You are not allowed to use commands.") + .build()).queue(); + return; + } + manager.handle(event); } catch (InsufficientPermissionException e) { try { @@ -136,6 +144,13 @@ public void onGuildMessageReceived(@NotNull GuildMessageReceivedEvent event) { @Override public void onSlashCommand(@NotNull SlashCommandEvent event) { + if (MongoMigrationCommand.isMigrating()) { + event.replyEmbeds(EmbedUtils.embedMessage("I am migrating databases at the moment!" + + " You are not allowed to use commands.") + .build()).queue(); + return; + } + if (new GuildConfig().isBannedUser(event.getGuild().getIdLong(), event.getUser().getIdLong())) event.replyEmbeds(EmbedUtils.embedMessage(BotConstants.BANNED_MESSAGE.toString()).build()) .queue();