functional reload, admin and disable trust levels, and more discord shit

This commit is contained in:
Parker2991 2024-08-21 12:20:11 -04:00
parent 2604709b53
commit 2f48ffea12
23 changed files with 261 additions and 119 deletions

View file

@ -3,7 +3,8 @@ const { EventEmitter } = require('events')
const fs = require('fs')
const path = require('path')
require("events").EventEmitter.defaultMaxListeners = Infinity;
function createBot(options = {}) {
const util = require('util');
function createBot(options = {}, config) {
const bot = new EventEmitter()
bot.options = {
// Set some default values in options
@ -25,17 +26,22 @@ function createBot(options = {}) {
bot.username = client.username
})
client.on('disconnect', (data) => {
bot.emit("disconnect", data.reason)
bot.emit("disconnect", JSON.stringify(data.reason))
bot?.discord?.channel?.send(util.inspect(data.reason))
if (config.console.filelogger) {
bot?.console?.filelogging(`[${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} logs] [${options.serverName}] ` + '[Client Reconnect] ' + util.inspect(data.reason))
}
})
client.on('end', reason => {
bot.emit('end', reason);
})
client.on('error', error => {
// bot.emit('error', error)
// console.log(error.toString())
bot.console.logs(ChatMessage.fromNotch('§8[§bClient Reconnect§8]§r ')?.toAnsi() + error.toString())
bot.console.logs(ChatMessage.fromNotch('§8[§bClient Reconnect§8]§r ')?.toAnsi() + util.inspect(error.toString()))
bot?.discord?.channel?.send(error.toString())
if (config.console.filelogger) {
bot?.console?.filelogging(`[${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} logs] [${options.serverName}] ` + '[Client Reconnect] ' + util.inspect(error.toString()))
}
})
client.on("keep_alive", ({ keepAliveId }) => {
@ -44,7 +50,11 @@ function createBot(options = {}) {
client.on('kick_disconnect', (data) => {
bot.emit("kick_disconnect", data.reason)
bot.console.logs(ChatMessage.fromNotch('§8[§bClient Reconnect§8]§r ')?.toAnsi() + data.toString())
bot.console.logs(ChatMessage.fromNotch('§8[§bClient Reconnect§8]§r ')?.toAnsi() + util.inspect(data.reason))
bot?.discord?.channel?.send(util.inspect(data.reason))
if (config.console.filelogger) {
bot?.console?.filelogging(`[${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} logs] [${options.serverName}] ` + '[Client Reconnect] ' + util.inspect(data.reason))
}
})
process.on("uncaughtException", (e) => {

View file

@ -1,6 +1,6 @@
module.exports = {
name: 'console',
trustLevel: 3,
trustLevel: 4,
aliases: [
],
@ -9,7 +9,7 @@ module.exports = {
const args = context.arguments;
const source = context.source;
if (!args && !args[0] && !args[1] && !args[2] && !args[3]) return;
switch (args[0]) {
switch (args[0]?.toLowerCase()) {
case "server":
case "svr":
const servers = bot.bots.map(eachBot => eachBot.options.serverName);
@ -29,8 +29,28 @@ module.exports = {
}
break
case "validate":
bot.chat.message(`${config.prefixes[0]}${args.slice(1).shift()} ${bot.validation.owner} ${args.slice(2).join(' ')}`)
case "validation":
case "val":
// bot.chat.message(`${config.prefixes[0]}${args.slice(1).shift()} ${bot.validation.owner} ${args.slice(2).join(' ')}`)
switch (args[1]?.toLowerCase()) {
case "owner":
case "o":
bot.chat.message(`${config.prefixes[0]}${args.slice(2).shift()} ${bot.validation.owner} ${args.slice(3).join(' ')}`)
break
case "admin":
case "a":
bot.chat.message(`${config.prefixes[0]}${args.slice(2).shift()} ${bot.validation.admin} ${args.slice(3).join(' ')}`)
break
case "trusted":
case "t":
bot.chat.message(`${config.prefixes[0]}${args.slice(2).shift()} ${bot.validation.trusted} ${args.slice(3).join(' ')}`)
break
default:
bot.chat.message(bot.getMessageAsPrismarine({ translate: "command.unknown.argument", color: "dark_red" })?.toMotd().replaceAll("§","&"))
}
break
default:
bot.chat.message(bot.getMessageAsPrismarine({ translate: "command.unknown.argument", color: "dark_red" })?.toMotd().replaceAll("§","&"))
}
}
}

View file

@ -27,19 +27,22 @@ module.exports = {
const source = context.source;
const args = context.arguments;
const category = {
translate: '(%s%s%s%s%s) \u203a ',
translate: '(%s%s%s%s%s%s%s) \u203a ',
bold: false,
color: 'gray',
with: [
{ color: "blue", text: 'Public'},
{ color: "aqua", text: 'Public'},
{ color: "gray", text: ' | '},
{ color: "dark_aqua", text: 'Trusted'},
{ color: 'gray', text: ' | '},
{ color: "blue", text: "Admin" },
{ color: "gray", text: " | " },
{ color: "dark_blue", text: 'Owner'},
]
}
let public = [];
let trusted = [];
let admin = [];
let owner = [];
for (const command of bot.commandManager.commandlist) {
if (args[0] === command.name) {
@ -76,7 +79,7 @@ module.exports = {
public.push([
{
text: command.name + ' ',
color: "blue",
color: "aqua",
translate: "",
hoverEvent:{
action:"show_text",
@ -147,6 +150,43 @@ module.exports = {
}
])
} else if (command.trustLevel === 2) {
admin.push([
{
text: command.name + ' ',
color: "blue",
translate: "",
hoverEvent:{
action:"show_text",
value:[
{
text: `Command:${command.name}\n`,
color: 'gray'
},
{
text: `Trust Level: `,
color: 'gray'
},
{
text: `${command.trustLevel}\n`,
color: 'red'
},
{
text: `${command.description}\n`,
color: 'gray'
},
{
text: `Command Aliases: ${command.aliases}\n`,
color: 'gray'
},
{
text: 'click on me to use me :)',
color: 'gray',
},
],
}
}
])
} else if (command.trustLevel === 3) {
owner.push([
{
text: command.name + ' ',
@ -185,7 +225,7 @@ module.exports = {
])
}
}
const length = bot.commandManager.commandlist.filter(c => c.trustLevel != 3).length
const length = bot.commandManager.commandlist.filter(c => c.trustLevel != 4).length
if (bot.options.useChat) {
bot.chat.message(bot.getMessageAsPrismarine([
{
@ -217,6 +257,7 @@ module.exports = {
'\n',
public,
trusted,
admin,
owner
])
}
@ -266,7 +307,7 @@ module.exports = {
}
])
} else if (command?.trustLevel === 2) {
} else if (command?.trustLevel === 3) {
owner.push([
{
text: command.name + ' ',

View file

@ -1,5 +1,9 @@
const os = require("os");
const CommandError = require('../util/command_error');
const fs = require("fs");
const botInfo = require('../data/info.json');
const fixansi = require('../util/ansi.js');
const { EmbedBuilder } = require('discord.js');
function format(seconds) {
function pad(s) {
return (s < 10 ? "0" : "") + s;
@ -11,6 +15,7 @@ function format(seconds) {
pad(`${minutes} Minutes`) + " " +
pad(`${seconds} Seconds`))
}
module.exports = {
name: 'info',
trustLevel: 0,
@ -23,8 +28,8 @@ module.exports = {
"config",
"discord",
"server",
"serverlist",
"contributors"
"contributors",
"about"
],
execute (context) {
const bot = context.bot;
@ -32,10 +37,10 @@ module.exports = {
const config = context.config;
const discordClient = context.discordClient;
const source = context.source;
switch (args[0]) {
switch (args[0]?.toLowerCase()) {
case 'version':
bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, `§9Friday §9Night §9Funkin §3Boyfriend §1Bot§8§r-v6.0.0-beta-#800-§#fe019aGraffiti §7Groovin\n11/22/22 - ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO" })}`);
break // &9 &3 &1
bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, `§9Friday §9Night §9Funkin §3Boyfriend §1Bot§8§r-${botInfo.bot.buildstring.version}-#${botInfo.bot.buildstring.build}-${botInfo.bot.buildstring.codename}\n11/22/22 - ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO" })}`);
break
case 'config':
bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, [
{
@ -89,7 +94,6 @@ module.exports = {
]);
break;
case 'discord':
// bot.tellraw('@a', config.discord.invite)
bot.tellraw("@a", [
{
text: `the discord server invite is ${config.discord.invite}`,
@ -171,15 +175,6 @@ module.exports = {
}
])
break
case "serverlist":
bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, [
{
text: "Servers \u203a\n",
color: "gray"
},
bot.bots.map((e) => e.options.serverName + "\n")
])
break
case "contributors":
bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, [
{
@ -224,8 +219,71 @@ module.exports = {
},
])
break
case "about":
bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, [
{
text: `FNFBoyfriendBot is a open source kaboom bot created by Parker2991\nThe source can be found here ${botInfo.bot.source}`,
color: "gray",
translate: "",
hoverEvent: {
action: "show_text",
value: [
{
text: "click here to view bots source code",
color: "gray",
}
]
},
clickEvent: {
action: "open_url",
value: `${botInfo.bot.source}`
}
}
])
break
default:
bot.chat.message(bot.getMessageAsPrismarine({ translate: "command.unknown.argument", color: "dark_red" })?.toMotd().replaceAll("§","&"))
}
},
discordExecute (context) {
const bot = context.bot;
const args = context.arguments;
const config = context.config;
const discordClient = context.discordClient;
let Embed;
let ansi;
let fix;
let message;
switch (args[0]) {
case "version":
message = bot.getMessageAsPrismarine(`§9Friday §9Night §9Funkin §3Boyfriend §1Bot§8§r-${botInfo.bot.buildstring.version}-#${botInfo.bot.buildstring.build}-${botInfo.bot.buildstring.codename}\n11/22/22 - ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO" })}`)?.toString()
fix = fixansi(message.replaceAll('`', '`\u200b'))
Embed = new EmbedBuilder()
.setColor(`${config.colors.discord.embed}`)
.setTitle(`${this.name} Command`)
.setDescription(`\`\`\`ansi\n${fix}\n\`\`\``)
bot.discord.message.reply({ embeds: [Embed] });
break
case "config":
message = bot.getMessageAsPrismarine([ { text: `Minecraft username \u203a ${bot.options.username}\n`, color: 'gray', }, { text: `Ip \u203a ${bot.options.host}:${bot.options.port}\n`, color: "gray" }, { text: `Version \u203a ${bot.options.version}\n`, color: "gray", }, { text: `Discord username \u203a ${discordClient.user.tag}\n`, color: 'gray', }, { text: `Channel \u203a ${bot.discord.channel?.name}\n`, color: "gray" }, { text: `Server name \u203a ${bot.options.serverName}\n`, color: "gray", }, { text: `Server count \u203a ${bot.bots.length}\n`, color: "gray" }, { text: `Prefixes \u203a ${config.prefixes.map((e) => e + " ").join(' ')}\n`, color: "gray" }, { text: `Prefix Length: ${config.prefixes.length}\n`, color: "gray" }, { text: `isKaboom \u203a ${bot.options.isKaboom}\n`, color: "gray", }, { text: `isCreayun \u203a ${bot.options.isCreayun}\n`, color: "gray", }, { text: `isSavage \u203a ${bot.options.isSavage}\n`, color: "gray", }, ])?.toAnsi();
fix = fixansi(message.replaceAll('`', '`\u200b'))
Embed = new EmbedBuilder()
.setColor(`${config.colors.discord.embed}`)
.setTitle(`${this.name} Command`)
.setDescription(`\`\`\`ansi\n${fix}\n\`\`\``)
bot.discord.message.reply({ embeds: [Embed] })
break
case "server":
message = bot.getMessageAsPrismarine([ { text: `Hostname \u203a ${os.hostname()}\n`, color: "gray" }, { text: `User \u203a ${os.userInfo().username}\n`, color: "gray", }, { text: `Working Directory \u203a ${process.mainModule.path}\n`, color: "gray" }, { text: `Arch \u203a ${os.arch()}\n`, color: "gray" }, { text: `OS \u203a ${os.platform()}\n`, color: "gray" }, { text: `OS Version/distro \u203a ${os.version()}\n`, color: "gray", }, { text: `Kernel Version \u203a ${os.release()}\n`, color: "gray" }, { text: `Cores \u203a ${os.cpus().length}\n`, color: "gray", }, { text: `CPU \u203a ${os.cpus()[0].model}\n`, color: "gray" }, { text: `Server Free memory `, color: 'gray' }, { text: `${Math.floor( os.freemem() / 1048576, )} `, color: 'gray' }, { text: `MiB / ${Math.floor(os.totalmem() / 1048576)} MiB\n`, color: 'gray' }, { text: `Device uptime \u203a ${format(os.uptime())}\n`, color: 'gray' }, { text: `Node version \u203a ${process.version}`, color: 'gray' } ])?.toString();
fix = fixansi(message.replace('`', '`\u200b'))
Embed = new EmbedBuilder()
.setColor(`${config.colors.discord.embed}`)
.setTitle(`${this.name} command`)
.setDescription(`\`\`\`ansi\n${fix}\n\`\`\``)
bot.discord.message.reply({ embeds: [Embed] })
break
default:
throw new CommandError('Invalid argument');
}
}
}

View file

@ -1,39 +0,0 @@
const { request } = require('undici');
const util = require('util');
module.exports = {
name: 'ipinfo',
trustLevel: 0,
aliases: [
],
description: 'Make me say something',
usages: [
"<message>"
],
async execute (context) {
const bot = context.bot;
const args = context.arguments;
try {
const url = await request(`https://get.geojs.io/v1/ip/geo/${args}.json`)
const outputJson = await url.body.json();
console.log(outputJson)
// bot.tellraw("@a", util.inspect(outputJson));
bot.tellraw("@a", [
{ text: `Ip \u203a `, color: "gray" },
{ text: `${outputJson.ip}\n`, color: "gold" },
{ text: `Country \u203a ${outputJson.country}\n`, color: "gray" },
{ text: `Region \u203a ${outputJson.region}\n`, color: "gray" },
{ text: `City \u203a ${outputJson.city}\n`, color: "gray" },
{ text: `Timezone \u203a ${outputJson.timezone}\n`, color: "gray" },
{ text: `Organization \u203a ${outputJson.organization_name}\n`, color: "gray" },
{ text: 'I dont leak cords dont worry :3' }
])
} catch (e) {
bot.tellraw("@a", { text: e.toString(), color: 'dark_red' })
}
},
discordExecute (context) {
const bot = context.bot;
const args = context.arguments;
}
}

View file

@ -2,7 +2,7 @@ const CommandError = require('../util/command_error');
const { EmbedBuilder } = require('discord.js');
module.exports = {
name: 'kick',
trustLevel: 1,
trustLevel: 2,
aliases: [
],
description: 'kick or crash players',
@ -19,6 +19,8 @@ module.exports = {
case 'invalidstring':
bot.core.run(`minecraft:tellraw ${args.slice(2).join(' ')} ${JSON.stringify(bot.exploits.invalidString)}`)
break
default:
bot.chat.message(bot.getMessageAsPrismarine({ translate: "command.unknown.argument", color: "dark_red" })?.toMotd().replaceAll("§","&"))
}
},
discordExecute (context) {

View file

@ -1,8 +1,9 @@
module.exports = {
name: 'kill',
trustLevel: 2,
trustLevel: 3,
aliases: [
"suicide",
"quit",
],
description: 'kill the bots process',
usages: [

View file

@ -12,16 +12,28 @@ module.exports = {
execute (context) {
const args = context.arguments;
const bot = context.bot;
const source = context.source
const source = context.source;
const config = context.config;
//throw new CommandError('ohio')
const component = {
translate: '[%s] %s \u203a %s',
color: "dark_gray",
with: [
if (config.patches.netmsg) {
component = [
{ text: '[', color: "dark_gray" },
{ text: bot.options.serverName, color: "gray" },
source.player.displayName ?? source.player.profile.name,
{ text: args.join(' '), color: "gray" },
{ text: "] ", color: "dark_gray" },
source.player.displayName,
{ text: " \u203a ", color: "dark_gray", bold: false },
{ text: args.join(' '), color: "gray", bold: false }
]
} else {
component = {
translate: '[%s] %s \u203a %s',
color: "dark_gray",
with: [
{ text: bot.options.serverName, color: "gray" },
source.player.displayName ?? source.player.profile.name,
{ text: args.join(' '), color: "gray" },
]
}
}
// bot.bots.filter((eachBot) => { if (eachBot.options.useChat) eachBot.chat.message('sussy');
// else if (!eachBot.options.useChat) eachBot.chat.message('baka!')})
@ -30,7 +42,6 @@ module.exports = {
bot.bots.filter((eachBot) => {
if (eachBot.options.serverName === "Savage Friends" && eachBot.options.isSavage && !eachBot.options.useChat && !eachBot.options.isKaboom) {
eachBot.chat.message(`[${bot.options.serverName}] ${bot.getMessageAsPrismarine(source.player.displayName ?? source.player.profile.name)?.toMotd().replaceAll('§','&')} \u203a ${args.join(' ')}`)
} else if (!eachBot.options.serverName !== "Savage Friends" && !eachBot.options.isSavage && !eachBot.options.useChat && eachBot.options.isKaboom) {
eachBot.tellraw("@a", component);
} else if (!eachBot.options.serverName !== "Savage Friends" && !eachBot.options.isSavage && eachBot.options.useChat && eachBot.options.isKaboom) {

View file

@ -13,5 +13,9 @@ module.exports = {
const bot = context.bot
const message = context.arguments.join(' ')
bot._client.end("disconnect :3")
},
discordExecute (context) {
const bot = context.bot;
bot._client.end("disconnect :3")
}
}

View file

@ -3,7 +3,7 @@ const { stylize } = require('../util/stylizeEval');
const util = require('util');
module.exports = {
name: 'servereval',
trustLevel: 2,
trustLevel: 3,
aliases: [
],
description: 'run code unisolated',

View file

@ -13,10 +13,28 @@ module.exports = {
const bot = context.bot;
const args = context.arguments;
const source = context.source;
/* if (args[0] === bot.validation.trusted) {
if (bot.options.isSavage) {
bot.chat.message('&2Valid Trusted hash');
} else {
bot.tellraw(`@a`, { text: "Valid Trusted hash", color: "dark_green" });
}
}
if (args[0] === bot.validation.owner) {
if (bot.options.isSavage) {
bot.chat.message("&2Valid Owner hash");
} else {
bot.tellraw(`@a`, { text: "Valid Owner hash", color: "dark_green" });
}
}*/
if (args[0] === bot.validation.trusted) {
bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, { text: "Valid Trusted hash", color: "dark_green" });
} if (args[0] === bot.validation.owner) {
bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, { text: "Valid Owner hash", color: "dark_green" });
bot.chat.message('&2Valid Trusted hash');
}
if (args[0] === bot.validation.admin) {
bot.chat.message('&2Valid Admin hash');
}
if (args[0] === bot.validation.owner) {
bot.chat.message('&2Valid Owner hash');
}
},
discordExecute (context) {

View file

@ -35,7 +35,7 @@ module.exports = {
console.log('statusCode:', res.statusCode);
console.log('headers:', res.headers);
res.on('data', (d) => {
bot.tellraw("@a", { text: util.inspect(d), color: "dark_green", })
bot.tellraw("@a", { text: util.inspect(d.toString()), color: "dark_green", })
});
}).on('error', (e) => {
bot.chat.message(`&4${e.toString()}`);

View file

@ -5,7 +5,7 @@ const fs = require('fs');
const path = require('path');
module.exports = {
name: 'xml',
trustLevel: 2,
trustLevel: 3,
aliases: [
],
description: 'eval xml shit',

10
src/data/info.json Normal file
View file

@ -0,0 +1,10 @@
{
"bot": {
"buildstring": {
"version": "v6.0.0-beta",
"build":"800",
"codename":"§#fe019aGraffiti §7Groovin"
},
"source": "https://code.chipmunk.land/Parker2991/FridayNightFunkinBoyfriendBot/"
}
}

View file

@ -1,2 +1,2 @@
<root> </root>
<sause></sauce><root> sex </root><root> sex </root><root> sex </root><root>sus</root><root<root> </root><root>sex</root><root> </root><root>sex</root><root><></root><root><></></root><root><amogus></amogus></root><root><amogus></amogus><sus></sus></root><root>hello :3</root>
<sause></sauce><root> sex </root><root> sex </root><root> sex </root><root>sus</root><root<root> </root><root>sex</root><root> </root><root>sex</root><root><></root><root><></></root><root><amogus></amogus></root><root><amogus></amogus><sus></sus></root><root>hello :3</root><root>mewo</root><sex>gex</sex>

View file

@ -27,8 +27,8 @@ const rl = readline.createInterface({
})
if (config.discord.enabled) discordClient.login(config.discord.token);
const bots = [];
for (options of config.bots) {
bot = createBot(options);
for (const options of config.bots) {
const bot = createBot(options, config);
bots.push(bot);
bot.bots = bots;
loadModules(bot, options, config, discordClient);

View file

@ -57,8 +57,8 @@ function core (bot, options, config) {
run (command) {
const location = bot.core.currentBlock()
if (!location) return
if (bot.options.useChat ?? bot.options.isCreayun ?? bot.options.isSavage) {
bot.chat.command(command?.substring(0, 256))
if (bot.options.isSavage || bot.options.isCreayun || bot.options.useChat) {
bot.chat.command(`${command?.substring(0, 256)}`)
} else {
bot._client.write('update_command_block', { command: command.substring(0, 32767), location, mode: 1, flags: 0b100 })
bot.core.incrementCurrentBlock()

View file

@ -60,19 +60,24 @@ function command_manager (bot, options, config, discordClient) {
const roles = event?.member?.roles?.cache;
if (command?.trustLevel === 1 && !source?.sources?.discord) {
const hash = args[0]
if (args.length === 0 && bot.validation.trusted && bot.validation.owner && !source.sources.console) throw new CommandError({ text: "Please provide an trusted or owner hash" })
if (args[0] !== bot.validation.trusted && args[0] !== bot.validation.owner && !source.sources.console) throw new CommandError({ translate: 'Invalid trusted or owner hash', color: 'dark_red' })
if (args.length === 0 && bot.validation.trusted && bot.validation.admin && bot.validation.owner && !source.sources.console) throw new CommandError({ text: "Please provide an trusted or and admin or an owner hash" })
if (args[0] !== bot.validation.trusted && args[0] !== bot.validation.admin && args[0] !== bot.validation.owner && !source.sources.console) throw new CommandError({ translate: 'Invalid trusted or admin or owner hash', color: 'dark_red' })
} else if (command?.trustLevel === 1 && source?.sources.discord) {
const hasRole = roles?.some(role => role.name === `${config.discord.roles.trusted}` || role.name === `${config.discord.roles.owner}`)
if (!hasRole) throw new CommandError({ translate: 'You are trusted or the owner!' })
if (!hasRole) throw new CommandError({ translate: 'You are not trusted or the owner!' })
}
if (command?.trustLevel === 2 && !source.sources.discord && !source.sources.console) {
if (command?.trustLevel === 2 && !source.sources.console) {
// bot.chat.message('trust level 2 does nothing currently'); placeholder code
if (args.length === 0 && bot.validation.admin && bot.validation.owner && !source.sources.console) throw new CommandError({ text: "Please provide an trusted or owner hash" })
if (args[0] !== bot.validation.trusted && args[0] !== bot.validation.owner && !source.sources.console) throw new CommandError({ translate: 'Invalid trusted or owner hash', color: 'dark_red' })
}
if (command?.trustLevel === 3 && !source.sources.discord && !source.sources.console) {
if (args.length === 0 && bot.validation.owner) throw new CommandError({ text: "Please provide an owner hash" })
if (args[0] !== bot.validation.owner) throw new CommandError({ translate: 'Invalid owner hash', color: 'dark_red' })
} else if (command?.trustLevel === 2 && source.sources.discord && !source.sources.console) {
} else if (command?.trustLevel === 3 && source.sources.discord && !source.sources.console) {
const hasRole = roles?.some(role => role.name === `${config.discord.roles.owner}`)
if (!hasRole) throw new CommandError({ translate: 'You are not the owner!' })
} else if (command?.trustLevel === 3 && !source.sources.console) {
} else if (command?.trustLevel === 4 && !source.sources.console) {
throw new CommandError('This command can only be ran via console');
}
} if (!command?.discordExecute && command && source.sources.discord) {
@ -87,7 +92,6 @@ function command_manager (bot, options, config, discordClient) {
} catch (error) {
console.error(error)
if (source?.sources?.discord && !source?.sources?.console) {
// if (error instanceof CommandError) {
const Embed = new EmbedBuilder()
.setColor(`${config.colors.discord.error}`)
.setTitle(`${command?.name} command`)
@ -97,8 +101,6 @@ function command_manager (bot, options, config, discordClient) {
Embed
]
})
// }
// bot.tellraw("@a", { text: `${error.stack}`, color: "dark_red" })
} else if (!source?.sources?.discord && !source?.sources?.console) {
if (error instanceof CommandError)
bot.tellraw("@a", { text: error.message, color: "dark_red" })
@ -106,12 +108,6 @@ function command_manager (bot, options, config, discordClient) {
}
}
},
/* const Embed = new EmbedBuilder()
.setColor(`${bot.Commands.colors.discord.error}`)
.setTitle(`${command?.name} Command`)
.setDescription(`\`\`\`${error}\`\`\``)
bot.discord.Message.reply({ embeds: [Embed] })
*/
executeString (source, command) {
const [commandName, ...args] = command.split(' ')
return this.execute(source, commandName, args)
@ -130,7 +126,8 @@ function command_manager (bot, options, config, discordClient) {
}
},
unregister (command) {
this.commands = {}
// commands = {};
this.commands = {};
},
getCommand (name) {
return this.commands[name]
@ -173,6 +170,8 @@ function command_manager (bot, options, config, discordClient) {
})
bot.commandManager.reload = function () {
commandlist = [];
bot.commandManager.unregister();
bot.commandManager.commandlist = [];
for (const filename of fs.readdirSync(path.join(__dirname, "../commands"))) {
try {
delete require.cache[require.resolve(path.join(__dirname, "../commands", filename))]
@ -180,7 +179,7 @@ function command_manager (bot, options, config, discordClient) {
// bot.commandManager.unregister(command);
// this.commands = {};
bot.commandManager.register(command);
bot.commandManager.commandlist.pop(command);
// bot.commandManager.commandlist.pop(command);
// bot.commandManager.register(command);
bot.commandManager.commandlist.push(command)
} catch (error) {

View file

@ -1,5 +0,0 @@
function database () {
}
module.exports = database;

View file

@ -40,7 +40,7 @@ function discord(bot, options, config, discordClient) {
try {
bot?.discord?.channel?.send(`\`\`\`ansi\n${discordQueue.join('\n').substring(0, 1984)}\n\`\`\``)
} catch (error) {
bot.console.error(error.stack)
bot.console.error(error.toString())
}
discordQueue = []

View file

@ -7,7 +7,9 @@ function selfcare (bot, options, config) {
let vanished = false;
let prefix = false;
let god = false;
let teleportToggle = false
let teleportToggle = false;
let username = false;
let nickname = false;
// You now have the tag: &8[&bPrefix&8: &3~&8]
// You no longer have a tag
bot.on('message', (message) => {
@ -23,8 +25,14 @@ function selfcare (bot, options, config) {
else if (stringMessage?.startsWith("Your voice has been silenced")) unmuted = true;
else if (stringMessage === "God mode disabled.") god = false;
else if (stringMessage === "God mode enabled.") god = true;
else if (stringMessage === "Teleportation disabled.") teleportToggle = false;
else if (stringMessage === "Teleportation enabled.") teleportToggle = true;
else if (stringMessage === "Teleportation disabled.") teleportToggle = true;
else if (stringMessage === "Teleportation enabled.") teleportToggle = false;
else if (stringMessage === `Successfully set your username to "${bot.username}"`) {
username = false
return
}
else if (stringMessage?.startsWith("Successfully set your username to ")) username = true
else if (stringMessage === `You already have the username "${bot.username}"`) username = false
})
bot.on('packet.entity_status', packet => {
if (packet.entityId !== entityId || packet.entityStatus < 24 || packet.entityStatus > 28) return
@ -43,7 +51,7 @@ function selfcare (bot, options, config) {
entityId = packet.entityId;
gameMode = packet.gameMode;
clientLock = packet.gameMode;
console.log(packet.gameMode);
// console.log(packet.gameMode);
timer = setInterval(() => {
if (bot.options.isSavage && !bot.options.isKaboom) {
if (clientLock !== 4) bot._client.write("client_command", { actionId: 0 });
@ -51,12 +59,14 @@ function selfcare (bot, options, config) {
if (permissionLevel < 2) bot.chat.command('op @s[type=player]');
else if (gameMode !== 1) bot.chat.command('gamemode creative @s[type=player]');
else if (!commandSpy) bot.chat.command('commandspy on');
else if (!vanished) bot.core.run(`vanish ${bot.options.username} on`);
else if (username) bot.chat.command(`username ${bot.options.username}`)
else if (!prefix) bot.chat.command(`prefix &8[&bPrefix&8: &3${config.prefixes[0]}&8]`);
else if (!vanished) bot.core.run(`vanish ${bot.options.username} on`);
else if (unmuted) bot.core.run(`essentials:mute ${bot.uuid}`);
else if (!god) bot.core.run(`god ${bot.options.username} enable`);
else if (!teleportToggle) bot.core.run(`tptoggle ${bot.options.username} enable`);
else if (!teleportToggle) bot.core.run(`tptoggle ${bot.options.username} disable`);
else if (clientLock !== 4) bot._client.write("client_command", { actionId: 0 });
// else if (username) bot.chat.command(`username ${bot.options.username}`)
// else if (unmuted) bot.chat.command(`mute ${bot.options.username} 0s`);
// else if (unmuted) bot.core.run(`/essentials:mute ${bot.options.username}`);
}
@ -70,6 +80,7 @@ function selfcare (bot, options, config) {
prefix = false;
god = false;
unmuted = false;
username = false;
});
}
module.exports = selfcare;

View file

@ -1,8 +1,9 @@
const crypto = require("crypto");
async function validation (bot, options, config, discordClient) {
function validation (bot, options, config, discordClient) {
let hashRegenInterval = setInterval(() => {
bot.validation = {
trusted: crypto.createHash('sha256').update(Math.floor(Date.now() / 5000) + config.keys.trusted).digest('hex').substring(0, 16),
admin: crypto.createHash('sha256').update(Math.floor(Date.now() / 5000) + config.keys.admin).digest('hex').substring(0, 16),
owner: crypto.createHash('sha256').update(Math.floor(Date.now() / 5000) + config.keys.owner).digest('hex').substring(0, 16),
}
}, 2000)