refactor: show disabled message and make music locking for non-console sender instead of all

This commit is contained in:
ChomeNS
2024-12-25 08:41:09 +07:00
parent eba4f92e45
commit 497155a827
3 changed files with 10 additions and 10 deletions

View File

@@ -1,10 +1,7 @@
package me.chayapak1.chomens_bot.commands;
import me.chayapak1.chomens_bot.Bot;
import me.chayapak1.chomens_bot.command.Command;
import me.chayapak1.chomens_bot.command.CommandContext;
import me.chayapak1.chomens_bot.command.CommandException;
import me.chayapak1.chomens_bot.command.TrustLevel;
import me.chayapak1.chomens_bot.command.*;
import me.chayapak1.chomens_bot.plugins.MusicPlayerPlugin;
import me.chayapak1.chomens_bot.song.Instrument;
import me.chayapak1.chomens_bot.song.Loop;
@@ -65,7 +62,7 @@ public class MusicCommand extends Command {
@Override
public Component execute(CommandContext context) throws CommandException {
if (context.bot.music.locked) throw new CommandException(Component.text("Managing music is currently locked"));
if (context.bot.music.locked && !(context instanceof ConsoleCommandContext)) throw new CommandException(Component.text("Managing music is currently locked"));
final String action = context.getString(false, true, true);

View File

@@ -84,14 +84,17 @@ public class CommandHandlerPlugin {
CommandContext context,
MessageReceivedEvent event
) {
if (disabled || commandPerSecond > 100) return null;
commandPerSecond++;
final boolean inGame = context instanceof PlayerCommandContext;
final boolean discord = context instanceof DiscordCommandContext;
final boolean console = context instanceof ConsoleCommandContext;
if (!console) {
if (disabled) return Component.text("ChomeNS Bot is currently disabled").color(NamedTextColor.RED);
else if (commandPerSecond > 100) return null;
}
commandPerSecond++;
final String[] splitInput = input.trim().split("\\s+");
if (splitInput.length == 0) return null;