mirror of
https://code.chipmunk.land/Parker2991/NitoriBot/
synced 2026-12-02 07:05:39 -05:00
rewrote the trust levels
This commit is contained in:
+1
-1
@@ -84,7 +84,7 @@ class Bot {
|
||||
});
|
||||
|
||||
process.on("uncaughtException", (e) => {
|
||||
bot.console.warn(`${e.stack}`);
|
||||
console.warn(`${e.stack}`);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ function chipmunkmod(message, data, context, bot) {
|
||||
sender,
|
||||
contents,
|
||||
type: "minecraft:chat",
|
||||
chatType: ["system"],
|
||||
senderComponent,
|
||||
chatType: data.chatType
|
||||
};
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
|
||||
@@ -15,8 +15,8 @@ function parseMessage(messageobj, data) {
|
||||
return {
|
||||
sender,
|
||||
contents: match[3],
|
||||
chatType: "player",
|
||||
type: "minecraft:chat",
|
||||
chatType: data.chatType
|
||||
};
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
@@ -31,7 +31,7 @@ function kaboom (message, data) {
|
||||
|
||||
if (!sender) return undefined
|
||||
|
||||
return { sender, contents, type: 'minecraft:chat', displayName, chatType: "minecraft:player_chat" }
|
||||
return { sender, contents, type: "minecraft:chat", displayName, chatType: data.chatType }
|
||||
}
|
||||
|
||||
function isSeparatorAt (children, start) {
|
||||
|
||||
@@ -27,8 +27,8 @@ function parseMessage(message, data, context) {
|
||||
sender,
|
||||
contents,
|
||||
type: "minecraft:chat",
|
||||
chatType: "minecraft:player_chat",
|
||||
senderComponent,
|
||||
chatType: data.chatType
|
||||
};
|
||||
} catch (e) {
|
||||
console.error(`${e.stack}`);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
class CommandContext {
|
||||
constructor(name, aliases, description, trustLevel, usages, playerOnly) {
|
||||
constructor(name, aliases, description, trustLevel, usages, playerChat) {
|
||||
this.data = {};
|
||||
this.data.name = name;
|
||||
this.data.aliases = aliases;
|
||||
this.data.description = description;
|
||||
this.data.trustLevel = trustLevel;
|
||||
this.data.usages = usages;
|
||||
this.data.playerOnly = playerOnly;
|
||||
this.data.playerChat = playerChat;
|
||||
}
|
||||
}
|
||||
module.exports = CommandContext;
|
||||
|
||||
@@ -3,12 +3,10 @@ const ChatMessage = require("prismarine-chat")("1.20.2");
|
||||
const stringify = (message) => new ChatMessage(message)?.toString();
|
||||
|
||||
class CommandError extends Error {
|
||||
constructor(message, filename, lineError, useChat) {
|
||||
super(stringify(message), filename, lineError, useChat);
|
||||
constructor(message, filename, lineError) {
|
||||
super(stringify(message), filename, lineError);
|
||||
this.name = "CommandError";
|
||||
this._message = message;
|
||||
return (this._useChat = useChat);
|
||||
// this._useChat = useChat
|
||||
}
|
||||
|
||||
get message() {
|
||||
|
||||
@@ -3,7 +3,8 @@ class CommandSource {
|
||||
this.player = player;
|
||||
this.sources = sources;
|
||||
this.ChatType = ChatType;
|
||||
this.player.hash = null;
|
||||
this.player.trustLevel = 0;
|
||||
this.player.validateBypass = null;
|
||||
}
|
||||
}
|
||||
module.exports = CommandSource;
|
||||
|
||||
@@ -5,6 +5,7 @@ class command_trust_level {
|
||||
owner = 3;
|
||||
console = 4;
|
||||
disabled = 5;
|
||||
|
||||
}
|
||||
|
||||
module.exports = command_trust_level;
|
||||
|
||||
@@ -11,7 +11,7 @@ class kick extends CommandContext {
|
||||
"kick a player from the server",
|
||||
trustLevel.admin,
|
||||
["invalidstring", "item", "te"],
|
||||
false,
|
||||
true,
|
||||
);
|
||||
}
|
||||
execute(context) {
|
||||
|
||||
@@ -10,11 +10,12 @@ class kill extends CommandContext {
|
||||
"kill the bots process",
|
||||
trustLevel.owner,
|
||||
[""],
|
||||
false,
|
||||
true,
|
||||
);
|
||||
}
|
||||
execute(context) {
|
||||
const bot = context.bot;
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-253
@@ -11,6 +11,7 @@ class help extends CommandContext {
|
||||
"see a list of commands",
|
||||
trustLevel.public,
|
||||
["<command>"],
|
||||
false
|
||||
);
|
||||
}
|
||||
|
||||
@@ -58,286 +59,33 @@ class help extends CommandContext {
|
||||
Public.push({
|
||||
text: commands.data.name + " ",
|
||||
color: config.colors.help.public,
|
||||
translate: "",
|
||||
hoverEvent: {
|
||||
action: "show_text",
|
||||
value: [
|
||||
{
|
||||
translate: "%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s",
|
||||
color: config.colors.commands.tertiary,
|
||||
with: [
|
||||
{
|
||||
text: "Command Name",
|
||||
color: config.colors.commands.primary,
|
||||
},
|
||||
{
|
||||
text: `${commands.data.name}`,
|
||||
color: config.colors.commands.secondary,
|
||||
},
|
||||
{
|
||||
text: "Trust Level",
|
||||
color: config.colors.commands.primary,
|
||||
},
|
||||
{
|
||||
text: `${commands.data.trustLevel}`,
|
||||
color: config.colors.integer,
|
||||
},
|
||||
{
|
||||
text: "Description",
|
||||
color: config.colors.commands.primary,
|
||||
},
|
||||
{
|
||||
text: `${commands.data.description}`,
|
||||
color: config.colors.commands.secondary,
|
||||
},
|
||||
{ text: "Aliases", color: config.colors.commands.primary },
|
||||
{
|
||||
text: `${commands.data.aliases}`,
|
||||
color: config.colors.commands.secondary,
|
||||
},
|
||||
{ text: "Usages", color: config.colors.commands.primary },
|
||||
{
|
||||
text: `${commands.data.usages}`,
|
||||
color: config.colors.commands.secondary,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
clickEvent: {
|
||||
action: "suggest_command",
|
||||
value: `${config.prefixes[0]}${commands.data.name}`,
|
||||
},
|
||||
});
|
||||
break;
|
||||
case 1:
|
||||
trusted.push({
|
||||
text: commands.data.name + " ",
|
||||
color: config.colors.help.trusted,
|
||||
translate: "",
|
||||
hoverEvent: {
|
||||
action: "show_text",
|
||||
value: [
|
||||
{
|
||||
translate: "%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s",
|
||||
color: config.colors.commands.tertiary,
|
||||
with: [
|
||||
{
|
||||
text: "Command Name",
|
||||
color: config.colors.commands.primary,
|
||||
},
|
||||
{
|
||||
text: `${commands.data.name}`,
|
||||
color: config.colors.commands.secondary,
|
||||
},
|
||||
{
|
||||
text: "Trust Level",
|
||||
color: config.colors.commands.primary,
|
||||
},
|
||||
{
|
||||
text: `${commands.data.trustLevel}`,
|
||||
color: config.colors.integer,
|
||||
},
|
||||
{
|
||||
text: "Description",
|
||||
color: config.colors.commands.primary,
|
||||
},
|
||||
{
|
||||
text: `${commands.data.description}`,
|
||||
color: config.colors.commands.secondary,
|
||||
},
|
||||
{ text: "Aliases", color: config.colors.commands.primary },
|
||||
{
|
||||
text: `${commands.data.aliases}`,
|
||||
color: config.colors.commands.secondary,
|
||||
},
|
||||
{ text: "Usages", color: config.colors.commands.primary },
|
||||
{
|
||||
text: `${commands.data.usages}`,
|
||||
color: config.colors.commands.secondary,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
clickEvent: {
|
||||
action: "suggest_command",
|
||||
value: `${config.prefixes[0]}${commands.data.name}`,
|
||||
},
|
||||
});
|
||||
break;
|
||||
case 2:
|
||||
admin.push({
|
||||
text: commands.data.name + " ",
|
||||
color: config.colors.help.admin,
|
||||
translate: "",
|
||||
hoverEvent: {
|
||||
action: "show_text",
|
||||
value: [
|
||||
{
|
||||
translate: "%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s",
|
||||
color: config.colors.commands.tertiary,
|
||||
with: [
|
||||
{
|
||||
text: "Command Name",
|
||||
color: config.colors.commands.primary,
|
||||
},
|
||||
{
|
||||
text: `${commands.data.name}`,
|
||||
color: config.colors.commands.secondary,
|
||||
},
|
||||
{
|
||||
text: "Trust Level",
|
||||
color: config.colors.commands.primary,
|
||||
},
|
||||
{
|
||||
text: `${commands.data.trustLevel}`,
|
||||
color: config.colors.integer,
|
||||
},
|
||||
{
|
||||
text: "Description",
|
||||
color: config.colors.commands.primary,
|
||||
},
|
||||
{
|
||||
text: `${commands.data.description}`,
|
||||
color: config.colors.commands.secondary,
|
||||
},
|
||||
{ text: "Aliases", color: config.colors.commands.primary },
|
||||
{
|
||||
text: `${commands.data.aliases}`,
|
||||
color: config.colors.commands.secondary,
|
||||
},
|
||||
{ text: "Usages", color: config.colors.commands.primary },
|
||||
{
|
||||
text: `${commands.data.usages}`,
|
||||
color: config.colors.commands.secondary,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
clickEvent: {
|
||||
action: "suggest_command",
|
||||
value: `${config.prefixes[0]}${commands.data.name}`,
|
||||
},
|
||||
});
|
||||
break;
|
||||
case 3:
|
||||
owner.push({
|
||||
text: commands.data.name + " ",
|
||||
color: config.colors.help.owner,
|
||||
translate: "",
|
||||
hoverEvent: {
|
||||
action: "show_text",
|
||||
value: [
|
||||
{
|
||||
translate: "%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s",
|
||||
color: config.colors.commands.tertiary,
|
||||
with: [
|
||||
{
|
||||
text: "Command Name",
|
||||
color: config.colors.commands.primary,
|
||||
},
|
||||
{
|
||||
text: `${commands.data.name}`,
|
||||
color: config.colors.commands.secondary,
|
||||
},
|
||||
{
|
||||
text: "Trust Level",
|
||||
color: config.colors.commands.primary,
|
||||
},
|
||||
{
|
||||
text: `${commands.data.trustLevel}`,
|
||||
color: config.colors.integer,
|
||||
},
|
||||
{
|
||||
text: "Description",
|
||||
color: config.colors.commands.primary,
|
||||
},
|
||||
{
|
||||
text: `${commands.data.description}`,
|
||||
color: config.colors.commands.secondary,
|
||||
},
|
||||
{ text: "Aliases", color: config.colors.commands.primary },
|
||||
{
|
||||
text: `${commands.data.aliases}`,
|
||||
color: config.colors.commands.secondary,
|
||||
},
|
||||
{ text: "Usages", color: config.colors.commands.primary },
|
||||
{
|
||||
text: `${commands.data.usages}`,
|
||||
color: config.colors.commands.secondary,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
clickEvent: {
|
||||
action: "suggest_command",
|
||||
value: `${config.prefixes[0]}${commands.data.name}`,
|
||||
},
|
||||
});
|
||||
break;
|
||||
case 4:
|
||||
Console.push({
|
||||
text: commands.data.name + " ",
|
||||
color: config.colors.help.console,
|
||||
translate: "",
|
||||
hoverEvent: {
|
||||
action: "show_text",
|
||||
value: [
|
||||
{
|
||||
translate: "%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s",
|
||||
color: config.colors.commands.tertiary,
|
||||
with: [
|
||||
{
|
||||
text: "Command Name",
|
||||
color: config.colors.commands.primary,
|
||||
},
|
||||
{
|
||||
text: `${commands.data.name}`,
|
||||
color: config.colors.commands.secondary,
|
||||
},
|
||||
{
|
||||
text: "Trust Level",
|
||||
color: config.colors.commands.primary,
|
||||
},
|
||||
{
|
||||
text: `${commands.data.trustLevel}`,
|
||||
color: config.colors.integer,
|
||||
},
|
||||
{
|
||||
text: "Description",
|
||||
color: config.colors.commands.primary,
|
||||
},
|
||||
{
|
||||
text: `${commands.data.description}`,
|
||||
color: config.colors.commands.secondary,
|
||||
},
|
||||
{ text: "Aliases", color: config.colors.commands.primary },
|
||||
{
|
||||
text: `${commands.data.aliases}`,
|
||||
color: config.colors.commands.secondary,
|
||||
},
|
||||
{ text: "Usages", color: config.colors.commands.primary },
|
||||
{
|
||||
text: `${commands.data.usages}`,
|
||||
color: config.colors.commands.secondary,
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
clickEvent: {
|
||||
action: "suggest_command",
|
||||
value: `${config.prefixes[0]}${commands.data.name}`,
|
||||
},
|
||||
});
|
||||
break;
|
||||
default:
|
||||
/* bot.chat.message(
|
||||
`fuck you ${commands.data.name} has a invalid trust level`,
|
||||
);*/
|
||||
}
|
||||
|
||||
if (
|
||||
|
||||
@@ -7,7 +7,9 @@ class list extends CommandContext {
|
||||
constructor() {
|
||||
super("list", ["pl", "playerlist"], "check whos online on the server", trustLevel.public, [
|
||||
"",
|
||||
]);
|
||||
],
|
||||
false,
|
||||
);
|
||||
}
|
||||
execute(context) {
|
||||
const bot = context.bot;
|
||||
|
||||
@@ -6,7 +6,7 @@ const trustLevel = new CommandTrustLevel();
|
||||
|
||||
class mcserver extends CommandContext {
|
||||
constructor() {
|
||||
super("mcserver", ["pingserver"], "pings minecraft servers", trustLevel.public, ["<ip>"]);
|
||||
super("mcserver", ["pingserver"], "pings minecraft servers", trustLevel.public, ["<ip>"], false);
|
||||
}
|
||||
|
||||
async execute(context) {
|
||||
|
||||
@@ -10,7 +10,7 @@ class refillcore extends CommandContext {
|
||||
"refill the bots core",
|
||||
trustLevel.public,
|
||||
[""],
|
||||
true,
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ class auth extends CommandContext {
|
||||
"auth through the bot so you dont need to use a hash everytime",
|
||||
trustLevel.trusted,
|
||||
[""],
|
||||
false,
|
||||
true,
|
||||
);
|
||||
}
|
||||
execute(context) {
|
||||
@@ -21,12 +21,10 @@ class auth extends CommandContext {
|
||||
const config = context.config;
|
||||
const uuid = source.player.uuid;
|
||||
let component = []
|
||||
|
||||
if (bot.auth.list.find((e) => e?.player === uuid))
|
||||
if (source.player.validateBypass)
|
||||
throw new CommandError(`You are already authed!`);
|
||||
|
||||
if (source.player.hash === "trusted") {
|
||||
source.player.authed = true;
|
||||
if (source.player.trustLevel === 1) {
|
||||
bot.auth.add({
|
||||
player: uuid,
|
||||
trustLevel: "trusted",
|
||||
@@ -36,8 +34,7 @@ class auth extends CommandContext {
|
||||
text: "Authed as Trusted",
|
||||
color: config.colors.help.trusted
|
||||
})
|
||||
} else if (source.player.hash === "admin") {
|
||||
source.player.authed = true;
|
||||
} else if (source.player.trustLevel === 2) {
|
||||
bot.auth.add({
|
||||
player: uuid,
|
||||
trustLevel: "admin",
|
||||
@@ -47,8 +44,7 @@ class auth extends CommandContext {
|
||||
text: "Authed as Admin",
|
||||
color: config.colors.help.admin
|
||||
})
|
||||
} else if (source.player.hash === "owner") {
|
||||
source.player.authed = true;
|
||||
} else if (source.player.trustLevel === 3) {
|
||||
bot.auth.add({
|
||||
player: source.player.uuid,
|
||||
trustLevel: "owner",
|
||||
|
||||
@@ -12,6 +12,7 @@ class cloop extends CommandContext {
|
||||
"loops commands",
|
||||
trustLevel.trusted,
|
||||
["add <interval> <command>", "remove <index>", "list", "clear"],
|
||||
true,
|
||||
);
|
||||
}
|
||||
execute(context) {
|
||||
|
||||
@@ -10,7 +10,7 @@ class reconnect extends CommandContext {
|
||||
"reconnect the bot",
|
||||
trustLevel.trusted,
|
||||
[""],
|
||||
false,
|
||||
true,
|
||||
);
|
||||
}
|
||||
execute(context) {
|
||||
|
||||
@@ -10,7 +10,7 @@ class validate extends CommandContext {
|
||||
"validate through the bot",
|
||||
trustLevel.trusted,
|
||||
[""],
|
||||
false,
|
||||
true,
|
||||
);
|
||||
}
|
||||
execute(context) {
|
||||
@@ -20,18 +20,18 @@ class validate extends CommandContext {
|
||||
const config = context.config;
|
||||
let component = []
|
||||
|
||||
if (source.player.hash === "trusted")
|
||||
if (source.player.trustLevel === 1)
|
||||
component.push({
|
||||
text: "Valid Trusted Hash",
|
||||
color: config.colors.help.trusted
|
||||
})
|
||||
|
||||
else if (source.player.hash === "admin")
|
||||
else if (source.player.trustLevel === 2)
|
||||
component.push({
|
||||
text: "Valid Admin Hash",
|
||||
color: config.colors.help.admin
|
||||
})
|
||||
else if (source.player.hash === "owner")
|
||||
else if (source.player.trustLevel === 3)
|
||||
component.push({
|
||||
text: "Valid Owner Hash",
|
||||
color: config.colors.help.owner
|
||||
|
||||
+1
-2
@@ -3,7 +3,6 @@ const readline = require("readline");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const loadModules = require("./util/loadModules");
|
||||
const loadPlugins = require("./util/loadPlugins");
|
||||
const { Client, GatewayIntentBits, Partials } = require("discord.js");
|
||||
const { MessageContent, GuildMessages, Guilds, DirectMessages } =
|
||||
GatewayIntentBits;
|
||||
@@ -50,7 +49,7 @@ for (const botOptions of config.bots) {
|
||||
loadModules(bot, options, config, discordClient);
|
||||
bot.console.readlineInterface(rl);
|
||||
}
|
||||
loadPlugins(bot, options, config, discordClient);
|
||||
|
||||
discordClient.on("messageCreate", (message) => {
|
||||
try {
|
||||
if (message.author.id === bot.discord.client.user.id) return;
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
yeah i know theres plugins and modules now but i didnt know what else to name it but
|
||||
modules are for files loaded from the bot array and plugins are for files needed to be loaded outside the bot array as a lazy fix
|
||||
+8
-4
@@ -16,7 +16,7 @@ function tryParse(json) {
|
||||
function parse (chatTypes, type, sender, target, message) {
|
||||
const chatType = chatTypes[type]
|
||||
const parsed = convertNbtComponentToJson(null, chatType.value.value.chat)
|
||||
const json = { translate: parsed.translation_key, with: [] }
|
||||
let json = { translate: parsed.translation_key, with: [] }
|
||||
|
||||
for (const parameter of parsed.parameters) {
|
||||
|
||||
@@ -29,6 +29,8 @@ function parse (chatTypes, type, sender, target, message) {
|
||||
}
|
||||
}
|
||||
|
||||
if (type === 4) json = message
|
||||
|
||||
return json
|
||||
}
|
||||
|
||||
@@ -68,6 +70,8 @@ class chat {
|
||||
type: "minecraft:disguised_chat",
|
||||
message: parsed
|
||||
})
|
||||
|
||||
tryParsingMessage(parsed, { senderName: sender, players: bot.players, getMessageAsPrismarine: bot.getMessageAsPrismarine, chatType: "minecraft:diguised_chat" })
|
||||
});
|
||||
|
||||
bot.on("packet.player_chat", (packet, data) => {
|
||||
@@ -81,7 +85,7 @@ class chat {
|
||||
senderUuid: packet.senderUuid,
|
||||
players: bot.players,
|
||||
getMessageAsPrismarine: bot.getMessageAsPrismarine,
|
||||
chatType: "player",
|
||||
chatType: "minecraft:player_chat"
|
||||
});
|
||||
});
|
||||
|
||||
@@ -106,11 +110,11 @@ class chat {
|
||||
});
|
||||
bot.emit("system_chat", message);
|
||||
|
||||
if (bot.options.mode !== "savageFriends") return;
|
||||
//if (bot.options.mode !== "savageFriends") return;
|
||||
tryParsingMessage(message, {
|
||||
players: bot.players,
|
||||
getMessageAsPrismarine: bot.getMessageAsPrismarine,
|
||||
chatType: "system",
|
||||
chatType: "minecraft:system_chat",
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
const nbt = require("prismarine-nbt");
|
||||
const sleep = require("../util/sleep");
|
||||
const convertNbtComponentToJson = require("../util/nbt_parser");
|
||||
const fixansi = require("../util/ansi");
|
||||
|
||||
class command_core {
|
||||
constructor(context) {
|
||||
@@ -9,6 +8,7 @@ class command_core {
|
||||
const config = context.config;
|
||||
const options = context.options;
|
||||
const Item = require("prismarine-item")(bot.options.version);
|
||||
|
||||
let command;
|
||||
|
||||
bot.core = {
|
||||
@@ -95,6 +95,8 @@ class command_core {
|
||||
z: Math.floor(pos.z),
|
||||
};
|
||||
|
||||
bot.core.commandBlocks = [];
|
||||
|
||||
if (bot.options.itemRefill && bot.options.mode !== "savageFriends") {
|
||||
bot.core.itemRefill();
|
||||
} else {
|
||||
@@ -240,31 +242,6 @@ class command_core {
|
||||
bot.on("end", () => {
|
||||
if (timer) clearInterval(timer);
|
||||
});
|
||||
|
||||
/* bot.on("packet.multi_block_change", (data) => {
|
||||
try {
|
||||
if (bot.options.mode !== "kaboom") return;
|
||||
|
||||
let broken = true;
|
||||
|
||||
if (
|
||||
data.chunkCoordinates.x === Math.floor(bot.core.position.x / 16) &&
|
||||
data.chunkCoordinates.y === Math.floor(bot.core.position.y / 16) &&
|
||||
data.chunkCoordinates.z === Math.floor(bot.core.position.z / 16)
|
||||
) {
|
||||
for (const state of data.records) {
|
||||
if (state >= 7906 && state >= 7917) broken = false;
|
||||
if (state >= 12527 && state >= 12538) broken = false;
|
||||
if (state >= 12515 && state >= 12526) broken = false;
|
||||
else broken = true;
|
||||
}
|
||||
|
||||
if (broken === true) bot.core.move(bot.position);
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e.stack);
|
||||
}
|
||||
});*/
|
||||
}
|
||||
}
|
||||
module.exports = command_core;
|
||||
|
||||
@@ -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;
|
||||
+48
-194
@@ -4,6 +4,7 @@ const CommandError = require("../command_util/command_error.js");
|
||||
const CommandSource = require("../command_util/command_source");
|
||||
const fixansi = require("../util/ansi");
|
||||
const sleep = require("../util/sleep.js");
|
||||
const trustLevels = require('../command_util/command_trust_level.js')
|
||||
|
||||
function unknownCommand(commandName, bot) {
|
||||
return {
|
||||
@@ -30,210 +31,62 @@ class command_manager {
|
||||
commandlist: [],
|
||||
execute(source, commandName, args) {
|
||||
const command = this.getCommand(commandName.toLowerCase());
|
||||
const authed = bot.auth.list;
|
||||
try {
|
||||
const authFind = bot.auth.list.find((e) => e.player === source.player.uuid)
|
||||
if (!command) {
|
||||
if (source?.sources?.console)
|
||||
bot.console.command(
|
||||
unknownCommand(commandName, bot),
|
||||
);
|
||||
else
|
||||
source.sendFeedback(
|
||||
unknownCommand(commandName, bot),
|
||||
);
|
||||
source.sendFeedback(
|
||||
unknownCommand(commandName, bot),
|
||||
);
|
||||
}
|
||||
|
||||
const event = bot.discord.message;
|
||||
const roles = event?.member?.roles?.cache;
|
||||
if (authFind) {
|
||||
source.player.validateBypass = true
|
||||
if (authFind.trustLevel === "trusted") source.player.trustLevel = 1;
|
||||
else if (authFind.trustLevel === "admin") source.player.trustLevel = 2;
|
||||
else if (authFind.trustLevel === "owner") source.player.trustLevel = 3;
|
||||
}
|
||||
|
||||
switch (command?.data?.trustLevel) {
|
||||
case 0:
|
||||
// do nothing since trust level 0 is public
|
||||
break;
|
||||
case 1:
|
||||
if (source?.sources?.discord) {
|
||||
const hasRole = roles?.some(
|
||||
(role) =>
|
||||
role.name === `${config.discord.roles.trusted}` ||
|
||||
role.name === `${config.discord.roles.admin}` ||
|
||||
role.name === `${config.discord.roles.fullAccess}` ||
|
||||
role.name === `${config.discord.roles.owner}`,
|
||||
);
|
||||
if (!hasRole)
|
||||
throw new CommandError({
|
||||
text: "You done have the trusted, admin, or owner roles!",
|
||||
color: "red"
|
||||
});
|
||||
} else if (!source?.sources.console) {
|
||||
if (source.ChatType === "extras:message")
|
||||
throw new CommandError({
|
||||
text: "Trusted Commands can not be ran from extras:message",
|
||||
color: "red"
|
||||
})
|
||||
if (
|
||||
args.length === 0 &&
|
||||
authed.find((e) => e?.player === source.player.uuid)
|
||||
?.trustLevel !== "trusted" &&
|
||||
authed.find((e) => e?.player === source.player.uuid)
|
||||
?.trustLevel !== "admin" &&
|
||||
authed.find((e) => e?.player === source.player.uuid)
|
||||
?.trustLevel !== "owner"
|
||||
)
|
||||
throw new CommandError({
|
||||
text: "Please provide a trusted, admin, or owner hash",
|
||||
color: "red"
|
||||
});
|
||||
if (
|
||||
args[0] !== bot.validation.trusted &&
|
||||
args[0] !== bot.validation.admin &&
|
||||
args[0] !== bot.validation.owner &&
|
||||
authed.find((e) => e.player === source.player.uuid)
|
||||
?.trustLevel !== "trusted" &&
|
||||
authed.find((e) => e.player === source.player.uuid)
|
||||
?.trustLevel !== "admin" &&
|
||||
authed.find((e) => e.player === source.player.uuid)
|
||||
?.trustLevel !== "owner"
|
||||
)
|
||||
throw new CommandError({
|
||||
text: "Invalid Hash",
|
||||
color: "red"
|
||||
});
|
||||
if (source.player.authed) {
|
||||
args = args;
|
||||
} else {
|
||||
args = args.slice(1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (source?.sources?.discord) {
|
||||
const hasRole = roles?.some(
|
||||
(role) =>
|
||||
role.name === `${config.discord.roles.admin}` ||
|
||||
role.name === `${config.discord.roles.fullAccess}` ||
|
||||
role.name === `${config.discord.roles.owner}`,
|
||||
);
|
||||
if (!hasRole)
|
||||
throw new CommandError({
|
||||
text: "You dont have the admin, or owner roles!",
|
||||
color: "red"
|
||||
});
|
||||
} else if (!source?.sources?.console) {
|
||||
if (source.ChatType === "extras:message")
|
||||
throw new CommandError({
|
||||
text: "Admin Commands can not be ran from extras:message",
|
||||
color: "red"
|
||||
})
|
||||
if (
|
||||
args.length === 0 &&
|
||||
authed.find((e) => e?.player === source.player.uuid)
|
||||
?.trustLevel !== "admin" &&
|
||||
authed.find((e) => e?.player === source.player.uuid)
|
||||
?.trustLevel !== "owner"
|
||||
)
|
||||
throw new CommandError({
|
||||
text: "Please provide a hash",
|
||||
color: "red"
|
||||
});
|
||||
if (
|
||||
args[0] !== bot.validation.admin &&
|
||||
args[0] !== bot.validation.owner &&
|
||||
authed.find((e) => e?.player === source.player.uuid)
|
||||
?.trustLevel !== "admin" &&
|
||||
authed.find((e) => e?.player === source.player.uuid)
|
||||
?.trustLevel !== "owner"
|
||||
)
|
||||
throw new CommandError({
|
||||
text: "Invalid hash",
|
||||
color: "red"
|
||||
});
|
||||
|
||||
if (source.player.authed) {
|
||||
args = args;
|
||||
} else {
|
||||
args = args.slice(1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (source?.sources?.discord) {
|
||||
const hasRole = roles?.some(
|
||||
(role) =>
|
||||
role.name === `${config.discord.roles.owner}` ||
|
||||
role.name === `${config.discord.roles.fullAccess}`,
|
||||
);
|
||||
if (!hasRole)
|
||||
throw new CommandError({
|
||||
text: "You dont have the owner role!",
|
||||
color: "red"
|
||||
});
|
||||
} else if (!source?.sources?.console) {
|
||||
if (source.ChatType === "extras:message")
|
||||
throw new CommandError({
|
||||
text: "Owner Commands can not be ran from extras:message",
|
||||
color: "red"
|
||||
})
|
||||
|
||||
if (
|
||||
args.length === 0 &&
|
||||
bot.validation.owner &&
|
||||
authed.find((e) => e?.player === source.player.uuid)
|
||||
?.trustLevel !== "owner"
|
||||
)
|
||||
throw new CommandError({
|
||||
text: "Please provide a hash",
|
||||
color: "red"
|
||||
});
|
||||
|
||||
if (
|
||||
args[0] !== bot.validation.owner &&
|
||||
authed.find((e) => e?.player === source.player.uuid)
|
||||
?.trustLevel !== "owner"
|
||||
)
|
||||
throw new CommandError({
|
||||
text: "Invalid hash",
|
||||
color: "red"
|
||||
});
|
||||
|
||||
if (source.player.authed) {
|
||||
args = args;
|
||||
} else {
|
||||
args = args.slice(1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (!source?.sources?.console) {
|
||||
if (command.data.trustLevel !== 0) {
|
||||
if (!source.player.validateBypass && !source.sources.console && !source.sources.discord) {
|
||||
if (args[0] === bot.validation.trusted)
|
||||
source.player.trustLevel = 1
|
||||
else if (args[0] === bot.validation.admin)
|
||||
source.player.trustLevel = 2
|
||||
else if (args[0] === bot.validation.owner)
|
||||
source.player.trustLevel = 3
|
||||
args = args.slice(1)
|
||||
if (source.player.trustLevel < command?.data?.trustLevel && !source.sources.console) {
|
||||
throw new CommandError({
|
||||
text: "This Command can only be ran via console",
|
||||
text: "Invalid Hash",
|
||||
color: "red"
|
||||
});
|
||||
})
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
throw new CommandError({
|
||||
text: "This Command has been disabled!",
|
||||
color: "red"
|
||||
});
|
||||
break;
|
||||
} if (source.sources.discord) {
|
||||
const event = bot.discord.message;
|
||||
const roles = event?.member?.roles?.cache;
|
||||
const hashRole = roles?.some((role) => {
|
||||
if (role.name === `${config.discord.roles.trusted}`) source.player.trustLevel = 1;
|
||||
else if (role.name === `${config.discord.roles.admin}`) source.player.trustLevel = 2;
|
||||
else if (role.name === `${config.discord.roles.owner}`) source.player.trustLevel = 3;
|
||||
})
|
||||
|
||||
if (source.player.trustLevel < command?.data?.trustLevel)
|
||||
throw new CommandError({
|
||||
text: "Invalid Role",
|
||||
color: "red"
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/* if (source.sources.discord) {
|
||||
discordClient.channels.cache
|
||||
.get("1361739286113685534")
|
||||
.send(
|
||||
`User: ${source.player.profile.name}, Command: ${command?.data?.name}, Args: ${args.join(" ")}, Time/Date: ${new Date().toLocaleString("en-us", { TimeZone: "America/Chicago" })}, Source: Discord`,
|
||||
);
|
||||
} else if (!source.sources.console) {
|
||||
discordClient.channels.cache
|
||||
.get("1361739286113685534")
|
||||
.send(
|
||||
`User: ${source.player.profile.name}, Command: ${command?.data?.name}, Args: ${args.join(" ")}, Time/Date: ${new Date().toLocaleString("en-us", { TimeZone: "America/Chicago" })}, Source: Minecraft, Server: ${bot.options.host}:${bot.options.port}`,
|
||||
);
|
||||
}*/
|
||||
|
||||
// if (command.playerOnly === true && source.ChatType.find((e) => e)) return;
|
||||
|
||||
if (
|
||||
command?.data.playerChat
|
||||
&&
|
||||
source.ChatType !== "minecraft:player_chat"
|
||||
&&
|
||||
!source.sources.console
|
||||
&&
|
||||
!source.sources.discord
|
||||
) return
|
||||
return command?.execute({
|
||||
bot,
|
||||
source,
|
||||
@@ -241,6 +94,7 @@ class command_manager {
|
||||
config,
|
||||
discordClient,
|
||||
});
|
||||
|
||||
} catch (error) {
|
||||
if (error instanceof CommandError) {
|
||||
|
||||
|
||||
@@ -23,8 +23,7 @@ class command_spy {
|
||||
) bot.emit("parsed_message", {
|
||||
sender: bot.players.find((e) => e.profile.name === message.text),
|
||||
contents: { text: command },
|
||||
type: "minecraft:chat",
|
||||
chatType: "command_spy",
|
||||
type: "extras:command_spy",
|
||||
displayName: bot.players.find(
|
||||
(e) => e.profile.name === message.text,
|
||||
).displayName,
|
||||
|
||||
@@ -38,6 +38,10 @@ class Console {
|
||||
});
|
||||
});
|
||||
},
|
||||
/*
|
||||
data.trustLevel,
|
||||
data.validateBypass
|
||||
*/
|
||||
source: new CommandSource(
|
||||
{
|
||||
profile: {
|
||||
@@ -46,6 +50,11 @@ class Console {
|
||||
uuid: bot._client.uuid,
|
||||
},
|
||||
{ console: true, discord: false },
|
||||
"minecraft:chat",
|
||||
{
|
||||
trustLevel: 4,
|
||||
validateBypass: true
|
||||
}
|
||||
),
|
||||
|
||||
refreshLine(...args) {
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
const sleep = require("../util/sleep");
|
||||
|
||||
class OwnerCheckModule {
|
||||
constructor(context) {
|
||||
const config = context.config;
|
||||
const bot = context.bot;
|
||||
const discordClient = context.discordClient;
|
||||
const options = context.options;
|
||||
|
||||
if (bot.options.mode === "savageFriends") return;
|
||||
bot.ownerAuthed = false;
|
||||
|
||||
discordClient.on("messageCreate", (message) => {
|
||||
if (
|
||||
message.content === `auth ${config.ownerAuth.uuid}` &&
|
||||
message.channelId == config.ownerAuth.channel
|
||||
) {
|
||||
message.reply(`Authenticated ${config.ownerAuth.uuid}`);
|
||||
bot.ownerAuthed = true;
|
||||
}
|
||||
});
|
||||
|
||||
bot.on("player_left", (data) => {
|
||||
if (data[0] === `${config.ownerAuth.uuid}` && bot.ownerAuthed === true) {
|
||||
bot.ownerAuthed = false;
|
||||
}
|
||||
// console.log(data[0])
|
||||
});
|
||||
|
||||
bot.on("message", async (data) => {
|
||||
// console.log(bot.players);
|
||||
// await sleep(1000)
|
||||
|
||||
for (const eachPlayer of bot.players) {
|
||||
if (
|
||||
eachPlayer.uuid === `${config.ownerAuth.uuid}` &&
|
||||
!bot.ownerAuthed
|
||||
) {
|
||||
bot.core.run(`minecraft:deop @a[name="${eachPlayer.profile.name}"]`);
|
||||
bot.core.run(
|
||||
`gamemode adventure @a[name="${eachPlayer.profile.name}"]`,
|
||||
);
|
||||
// bot.core.run(`mute ${eachPlayer.uuid} 10y not authenticated`);
|
||||
bot.exploits.kicks.translateEntity(`${eachPlayer.profile.name}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
bot.on("parsed_message", (data) => {
|
||||
if (
|
||||
data?.sender?.uuid === `${config.ownerAuth.uuid}` &&
|
||||
!bot.ownerAuthed
|
||||
) {
|
||||
bot.core.run(`mute ${data.sender.uuid} 10y not authenticated`);
|
||||
}
|
||||
});
|
||||
|
||||
bot.on("end", () => (bot.ownerAuthed = false));
|
||||
}
|
||||
}
|
||||
module.exports = OwnerCheckModule;
|
||||
@@ -1,4 +0,0 @@
|
||||
class database {
|
||||
constructor(context) {}
|
||||
}
|
||||
module.exports = database;
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 139 KiB |
@@ -1,20 +0,0 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
async function loadPlugins(bot, options, config, discordClient) {
|
||||
bot.plugins = [];
|
||||
for (const filename of fs.readdirSync(
|
||||
path.join(__dirname, "../", "plugins"),
|
||||
)) {
|
||||
try {
|
||||
if (filename.endsWith(".js")) {
|
||||
const plugin = require(path.join(__dirname, "../plugins", filename));
|
||||
bot.plugins.push(module);
|
||||
new plugin({ bot, options, config, discordClient });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Failed to load plugin ${filename} due to error`);
|
||||
console.error(`\x1b[31m${error.stack}\x1b[0m`);
|
||||
}
|
||||
}
|
||||
}
|
||||
module.exports = loadPlugins;
|
||||
Reference in New Issue
Block a user