rename group

This commit is contained in:
ChomeNS
2024-10-06 17:36:42 +07:00
parent ed0b91ce40
commit 837fe388bb
156 changed files with 613 additions and 605 deletions

View File

@@ -0,0 +1,61 @@
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 net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
import net.kyori.adventure.text.event.HoverEvent;
import net.kyori.adventure.text.format.NamedTextColor;
import java.util.List;
public class NetMessageCommand extends Command {
public NetMessageCommand () {
super(
"netmsg",
"Broadcasts a message to all of the servers that the bot is connected",
new String[] { "<message>" },
new String[] { "networkmessage", "irc" },
TrustLevel.PUBLIC,
false
);
}
@Override
public Component execute(CommandContext context) throws CommandException {
final Bot bot = context.bot;
final List<Bot> bots = bot.bots;
final String hostAndPort = bot.host + ":" + bot.port;
final Component component = Component.translatable(
"[%s]%s%s%s %s",
Component
.text(hostAndPort)
.color(NamedTextColor.GRAY)
.clickEvent(ClickEvent.copyToClipboard(hostAndPort))
.hoverEvent(
HoverEvent.showText(
Component.empty()
.append(Component.text(hostAndPort).color(NamedTextColor.GRAY))
.append(Component.newline())
.append(Component.text("Click here to copy the server host and port to your clipboard").color(NamedTextColor.GREEN))
)
),
Component.text(" "),
context.sender.displayName == null ? Component.text(context.sender.profile.getName()).color(NamedTextColor.GRAY) : context.sender.displayName.color(NamedTextColor.GRAY),
Component.text(" "),
Component.text(context.getString(true, true)).color(NamedTextColor.GRAY)
).color(NamedTextColor.DARK_GRAY);
for (Bot eachBot : bots) {
if (!eachBot.loggedIn) continue;
eachBot.chat.tellraw(component);
}
return null;
}
}