forked from afspiegeling/NitoriBot
added fallback partically to commands *yes i know its shit*, made the prefix selfcare check the display and more
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const CommandError = require("../command_util/command_error.js");
|
||||
const CommandError = require("../command_util/command_error");
|
||||
const CommandSource = require("../command_util/command_source");
|
||||
const CommandArguments = require('../command_util/command_arguments')
|
||||
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 {
|
||||
@@ -25,6 +25,7 @@ class command_manager {
|
||||
const config = context.config;
|
||||
const discordClient = context.discordClient;
|
||||
const options = context.options;
|
||||
const translations = bot.translations;
|
||||
|
||||
bot.commandManager = {
|
||||
commands: {},
|
||||
@@ -34,11 +35,21 @@ class command_manager {
|
||||
try {
|
||||
const authFind = bot.auth.list.find((e) => e.player === source.player.uuid)
|
||||
if (!command) {
|
||||
source.sendFeedback(
|
||||
throw new CommandError(
|
||||
unknownCommand(commandName, bot),
|
||||
);
|
||||
}
|
||||
|
||||
if (args.length > command.data.args) throw new CommandError({
|
||||
translate: "fnfboyfriendbot.arguments",
|
||||
fallback: translations["fnfboyfriendbot.arguments"],
|
||||
color: "red",
|
||||
with: [
|
||||
{ text: `${command.data.args}` },
|
||||
{ text: `${args.length}`}
|
||||
]
|
||||
})
|
||||
|
||||
if (authFind) {
|
||||
source.player.validateBypass = true
|
||||
if (authFind.trustLevel === "trusted") source.player.trustLevel = 1;
|
||||
@@ -46,7 +57,7 @@ class command_manager {
|
||||
else if (authFind.trustLevel === "owner") source.player.trustLevel = 3;
|
||||
}
|
||||
|
||||
if (command?.data?.trustLevel !== 0) {
|
||||
if (command?.data?.trustLevel !== 0 && command?.data.trustLevel < 4) {
|
||||
if (!source.player.validateBypass && !source.sources.console && !source.sources.discord) {
|
||||
if (args[0] === bot.validation.trusted)
|
||||
source.player.trustLevel = 1
|
||||
@@ -54,10 +65,24 @@ class command_manager {
|
||||
source.player.trustLevel = 2
|
||||
else if (args[0] === bot.validation.owner)
|
||||
source.player.trustLevel = 3
|
||||
|
||||
if (args[0] === bot.validation.discord.trusted) {
|
||||
source.player.trustLevel = 1
|
||||
bot.validation.discord.trusted = undefined;
|
||||
} else if (args[0] === bot.validation.discord.admin) {
|
||||
source.player.trustLevel = 2;
|
||||
bot.validation.discord.admin = undefined;
|
||||
} else if (args[0] === bot.validation.discord.owner) {
|
||||
console.log(args[0])
|
||||
console.log(bot.validation.discord.owner)
|
||||
source.player.trustLevel = 3
|
||||
bot.validation.discord.owner = undefined
|
||||
}
|
||||
args = args.slice(1)
|
||||
if (source.player.trustLevel < command?.data?.trustLevel && !source.sources.console) {
|
||||
throw new CommandError({
|
||||
text: "Invalid Hash",
|
||||
translate: "fnfboyfriendbot.commandManager.validation.invalid_hash",
|
||||
fallback: translations["fnfboyfriendbot.commandManager.validation.invalid_hash"],
|
||||
color: "red"
|
||||
})
|
||||
}
|
||||
@@ -72,11 +97,17 @@ class command_manager {
|
||||
|
||||
if (source.player.trustLevel < command?.data?.trustLevel)
|
||||
throw new CommandError({
|
||||
text: "Invalid Role",
|
||||
translate: "fnfboyfriendbot.commandManager.validation.invalid_role",
|
||||
fallback: translations["fnfboyfriendbot.commandManager.validation.invalid_role"],
|
||||
color: "red"
|
||||
})
|
||||
}
|
||||
}
|
||||
} if (command?.data?.trustLevel === 4 && !source.sources.console)
|
||||
throw new CommandError({
|
||||
translate: "fnfboyfriendbot.commandManager.trustLevel.consoleOnly",
|
||||
fallback: translations["fnfboyfriendbot.commandManager.trustLevel.consoleOnly"],
|
||||
color: "red"
|
||||
})
|
||||
|
||||
if (
|
||||
command?.data.playerChat
|
||||
@@ -86,6 +117,8 @@ class command_manager {
|
||||
!source.sources.console
|
||||
&&
|
||||
!source.sources.discord
|
||||
&&
|
||||
bot.options.mode === 'kaboom'
|
||||
) return
|
||||
return command?.execute({
|
||||
bot,
|
||||
@@ -97,7 +130,6 @@ class command_manager {
|
||||
|
||||
} catch (error) {
|
||||
if (error instanceof CommandError) {
|
||||
|
||||
source.sendFeedback(error._message);
|
||||
} else {
|
||||
bot.console.error(error.stack)
|
||||
|
||||
Reference in New Issue
Block a user