rewrote the trust levels

This commit is contained in:
Parker2991
2025-09-12 12:54:08 -05:00
parent d2e2124fbe
commit a76e65b18f
34 changed files with 107 additions and 1343 deletions
+5 -45
View File
@@ -8,8 +8,8 @@ class command_handler {
const options = context.options;
bot.on("parsed_message", (data) => {
try {
if (data.type !== "minecraft:chat") return;
try {
if (data.type !== "minecraft:chat" && data.type !== "extras:command_spy") return;
const prefixes = config.prefixes;
prefixes.map((prefix) => {
const plainMessage = bot
@@ -18,12 +18,13 @@ class command_handler {
if (!plainMessage?.startsWith(prefix)) return;
const command = plainMessage.substring(prefix.length);
const source = new CommandSource(
data.sender,
{ discord: false, console: false },
data.chatType,
null,
data.trustLevel,
data.validateBypass
);
source.sendFeedback = (message) => {
@@ -33,13 +34,6 @@ class command_handler {
else bot.tellraw(`@a[name="${source.player.profile.name}"]`, message)
}
if (command.split(" ")[1] === bot.validation.trusted)
source.player.hash = "trusted";
else if (command.split(" ")[1] === bot.validation.admin)
source.player.hash = "admin";
else if (command.split(" ")[1] === bot.validation.owner)
source.player.hash = "owner";
else source.player.trustLevel = "public"
ratelimit++;
setTimeout(() => {
ratelimit--;
@@ -55,40 +49,6 @@ class command_handler {
console.log(e.stack);
}
});
bot.on('packet.custom_payload', (packet) => {
if (packet.channel === "extras:message") {
try {
const decoded = packet.data.toString('ascii');
const prefixes = config.prefixes
const string = decoded.substring(20)
const channel = packet.data.toString('ascii').split('\x05')[0]
if (channel === config.skibot.channel) return
const parsed = JSON.parse(string)
const args = parsed.message
const uuid = parsed.player
prefixes.map((prefix) => {
if (!args?.startsWith(prefix)) return;
const command = args.substring(prefix.length)
const sender = bot.players.find((e) => e.uuid === uuid)
const source = new CommandSource(
sender,
{ discord: false, console: false },
'extras:message',
null,
)
console.log(source.player.profile.name)
source.sendFeedback = (message) => {
bot.tellraw(`@a[name="${source.player.profile.name}"]`, message)
}
bot.commandManager.executeString(source, command)
})
} catch (e) {
bot.console.error(e.toString())
}
}
})
}
}
module.exports = command_handler;