role Bug
Closed this issue · 0 comments
import { Command, BeforeEvents, PlayerClass, Timer, ChatClass, Formatter } from "../class.chain.js";
import { RankConfig } from "./config.js";
import { world, Player, EntityHealthComponent, system } from "@minecraft/server";
BeforeEvents.on("chat", async (data) => {
const { message, sender } = data;
if (message.startsWith(Command.getPrefix())) return;
data.cancel = true;
let rgbtext = "";
const RoleConfig = {
doctor: "§l§cD§4r",
supreme: "§cSUP§4REME",
legend: §l§6of LEGEND
,
rainbow: Formatter.rainbowText(rgbtext)
};
let RoleFree = ""
const player = new PlayerClass(sender);
let roleTag = player.getTagStartsWith("role:")?.slice(5) ?? RoleFree;
const rankTag = player.getTagStartsWith("rank:")?.slice(5) ?? RankConfig.defaultRank;
if (roleTag && RoleConfig[roleTag]) {
roleTag = RoleConfig[roleTag];
}
let displayTag = null;
if (!roleTag || roleTag !== ("legend" || "rainbow")) {
displayTag = [${rankTag}§r]
;
} else {
displayTag = [${rankTag}§r] ${roleTag}
;
}
let nameDisplay = ${displayTag} ${sender.nameTag}
;
if (!player.getTagStartsWith("role:legend")?.slice(5)) {
nameDisplay = ${displayTag} ${sender.nameTag}
;
} else {
nameDisplay = ${displayTag} §l§6${sender.nameTag} ${RoleConfig.legend}
;
}
if (!player.getTagStartsWith("role:rainbow")?.slice(5)) {
nameDisplay = ${displayTag} ${sender.nameTag}
;
} else {
rgbtext = sender.name;
nameDisplay = ${displayTag} ${sender.name}
;
}
if (roleTag !== (player.getTagStartsWith("role:legend")?.slice(5) && player.getTagStartsWith("role:rainbow")?.slice(5))) {
nameDisplay = ${displayTag} ${sender.nameTag}
;
} else {
rgbtext = sender.name;
nameDisplay = ${displayTag} ${sender.name} ${RoleConfig.legend}
;
}
await Timer.sleep(2);
new ChatClass().broadcast({
text: ${nameDisplay} §r§l>§d>§r ${message}
,
});
});
Issue Details
⚠ Do not edit this section. It is required for Discord to GitHub issue linking.
- User: N.....POLOS#8302
- Server: ORDINAL-UNIVERSE