feat,refactor: add click event and insertion for HelpCommand (idea from Werkku) and some refactoring

This commit is contained in:
ChomeNS
2024-12-10 14:03:44 +07:00
parent 935dfdcb32
commit 15835d7ac6
2 changed files with 6 additions and 13 deletions

View File

@@ -9,6 +9,7 @@ import me.chayapak1.chomens_bot.plugins.CommandHandlerPlugin;
import me.chayapak1.chomens_bot.util.ColorUtilities;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.JoinConfiguration;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.event.HoverEvent;
import net.kyori.adventure.text.format.NamedTextColor;
@@ -85,6 +86,10 @@ public class HelpCommand extends Command {
Component
.text(name)
.color(getColorByTrustLevel(trustLevel))
.clickEvent(
ClickEvent.suggestCommand(context.prefix + name) // *command
)
.insertion(context.prefix + this.name + " " + name) // *help <command>
.hoverEvent(
HoverEvent.showText(
sendUsages(context, name)
@@ -138,18 +143,6 @@ public class HelpCommand extends Command {
.append(Component.text(prefix + actualCommandName).color(ColorUtilities.getColorByString(bot.config.colorPalette.secondary)))
.append(Component.text(" "));
if (command.trustLevel == TrustLevel.TRUSTED) {
usageComponent = usageComponent
.append(Component.text("<hash>"))
.append(Component.space())
.color(ColorUtilities.getColorByString(bot.config.colorPalette.string));
} else if (command.trustLevel == TrustLevel.OWNER) {
usageComponent = usageComponent
.append(Component.text("<ownerHash>"))
.append(Component.space())
.color(ColorUtilities.getColorByString(bot.config.colorPalette.string));
}
usageComponent = usageComponent.append(Component.text(usage).color(ColorUtilities.getColorByString(bot.config.colorPalette.string)));
usages.add(usageComponent);