FridayNightFunkinBoyfriendBot/commands/help.js

280 lines
13 KiB
JavaScript
Raw Normal View History

2023-12-17 14:55:27 -05:00
const CommandError = require('../CommandModules/command_error')
module.exports = {
name: 'help',
aliases:['heko', 'cmd', '?', 'commands', 'cmds' ],
description:['shows the command list'],
2023-12-20 11:54:03 -05:00
trustLevel: 0,
2023-12-17 14:55:27 -05:00
async execute (context) {
const bot = context.bot
const commandList = []
const source = context.source
const args = context.arguments
// const amogus = bot.prefix
const ChatMessage = require('prismarine-chat')(bot.options.version)
const cmd = {
2023-12-17 14:55:27 -05:00
translate: '[%s] ',
bold: false,
color: 'white',
with: [
{ color: 'blue', text: 'Help Cmd'},
]
}
const category = {
translate: ' (%s%s%s%s%s) ',
bold: false,
color: 'white',
with: [
2024-01-12 12:24:01 -05:00
{ color: '#00FFFF', text: 'Public'},
2023-12-17 14:55:27 -05:00
{ color: 'white', text: ' | '},
2024-01-12 12:24:01 -05:00
{ color: 'dark_purple', text: 'Trusted'},
2023-12-17 14:55:27 -05:00
{ color: 'white', text: ' | '},
{ color: 'dark_red', text: 'Owner'},
]
}
if (args[0]) {
let valid
2024-01-12 12:24:01 -05:00
for (const commands in bot.commandManager.commandlist) { // i broke a key woops
const command = bot.commandManager.commandlist[commands]
2023-12-17 14:55:27 -05:00
if (args[0].toLowerCase() === command.name )
// if (args[0].toLowerCase() === command.aliases)
2023-12-20 11:54:03 -05:00
{//text:`Trust Level: `,color:'white'},
//{text:`${command.trustLevel}\n`,color:'red'},
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}//bot.getMessageAsPrismarine([cmd, 'Commands (', length, ') ', category, ...pub_lick, t_rust, own_her, cons_ole])?.toAnsi()
2023-12-17 14:55:27 -05:00
valid = true
if(source.sources.console){
bot.console.info(bot.getMessageAsPrismarine([cmd, `Description: ${command.description}`])?.toAnsi())
bot.console.info(bot.getMessageAsPrismarine([cmd, {text:`Trust Level: ${command.trustLevel}`}])?.toAnsi())//[cmd, {text:`Trust Level: ${command.trustLevel}`}]
bot.console.info(bot.getMessageAsPrismarine([cmd, `aliases: ${command.aliases}`])?.toAnsi())
}else if(!bot.options.Core.CorelessMode && !source.sources.console){
bot.chat(ChatMessage.fromNotch([cmd, `Description: ${command.description}`]).toMotd().replaceAll('§', '&'))
await sleep(1000)
bot.chat(ChatMessage.fromNotch([cmd, {text:`Trust Level: ${command.trustLevel}`}]).toMotd().replaceAll('§', '&'))//[cmd, {text:`Trust Level: ${command.trustLevel}`}]
await sleep(1000)
bot.chat(ChatMessage.fromNotch([cmd, `aliases: ${command.aliases}`]).toMotd().replaceAll('§', '&'))
}else{
source.sendFeedback([cmd, `Description: ${command.description}`])
2023-12-20 11:54:03 -05:00
source.sendFeedback([cmd, {text:`Trust Level: ${command.trustLevel}`}])
2023-12-17 14:55:27 -05:00
source.sendFeedback([cmd, `aliases: ${command.aliases}`])
break
}
} else valid = false
2023-12-17 14:55:27 -05:00
}
2023-12-17 14:55:27 -05:00
//source is defined btw
//source.sendFeedback([cmd, 'This command is ' + valid + ' to this for loop'])
if (valid) {
} else {
const args = context.arguments
source.sendFeedback([cmd, {translate: `Unknown command %s. Type "${bot.options.commands.prefixes[0]}help" for help or click on this for the command`,color:'red', with: [args[0]], clickEvent: bot.options.Core.customName ? { action: 'suggest_command', value: `${bot.options.commands.prefixes[0]}help` } : undefined}])
2023-12-17 14:55:27 -05:00
// bot.tellraw([cmd, {translate: `Unknown command %s. Type "${bot.options.commands.prefix}help" for help or click on this for the command`, with: [args[0]], clickEvent: bot.options.Core.customName ? { action: 'suggest_command', value: `${bot.options.commands.prefix}help`, color:'red' } : undefined}])
}//i will add the descriptions reading as tests and action add the descriptions for the commands after
2024-01-12 12:24:01 -05:00
const length = context.bot.commandManager.commandlist.length // ok
2023-12-17 14:55:27 -05:00
//i guess i did delete smh woops
//context.source.sendFeedback([cmd, 'Commands (', length, ') ', category, ...commandList], false)
} else {
let pub_lick = []
let t_rust = []
let own_her = []
let cons_ole = []
2024-01-12 12:24:01 -05:00
for (const commands in bot.commandManager.commandlist) {
const command = bot.commandManager.commandlist[commands]
2023-12-17 14:55:27 -05:00
// if (command.consoleOnly == true) return console.log(command);
2023-12-20 11:54:03 -05:00
if(command.trustLevel === 3) {
2023-12-17 14:55:27 -05:00
cons_ole.push(
{
text: command.name + ' ',
color: 'blue',
translate:"",
hoverEvent:{
action:"show_text",
value:[
{
text:`Command:${command.name}\n`,
color:'white'
},{
text:"HashOnly:",
color:'white'},
{text:`${command.hashOnly}\n`,color:'red'},
{text:'consoleOnly:',color:'white'},
{text:`${command.consoleOnly && !context.console}\n`, color:'red'},
{text:`${command.description}\n`, color:'white'},
{text:`Command Aliases: ${command.aliases}\n`,color:'white'},
{text:'click on me to use me :)'},
]
}
}
)// copypasted from below, and removed stuff that wont work in the console
}
else
2023-12-20 11:54:03 -05:00
if (command.trustLevel === 2) {
if(!bot.options.Core.CorelessMode && !source.sources.console){
own_her.push(`&4${command.name + ' '}`)
}else{
2023-12-17 14:55:27 -05:00
own_her.push(
{
text: command.name + ' ',
color: 'dark_red',
translate:"",
hoverEvent:{
action:"show_text",
value:[
{
text:`Command:${command.name}\n`,
color:'white'
2023-12-20 11:54:03 -05:00
}, {text:`Trust Level: `,color:'white'},
{text:`${command.trustLevel}\n`,color:'dark_red'},
{text:`${command.description}\n`, color:'white'},
2023-12-17 14:55:27 -05:00
{text:`Command Aliases: ${command.aliases}\n`,color:'white'},
{text:'click on me to use me :)'},
]
},clickEvent:{
action:"run_command",value:`${bot.options.commands.prefixes[0]}${command.name}`
2023-12-17 14:55:27 -05:00
},
// ${command.name}\nhashOnly:§c${command.hashOnly}§r\nconsoleOnly:§c${command.consoleOnly && !context.console}§r\n${command.description}
///tellraw @a {"translate":"","hoverEvent":{"action":"show_text","value":[{"text":""},{"text":""}]},"clickEvent":{"action":"run_command","value":"a"}}
2024-01-12 12:24:01 -05:00
2023-12-17 14:55:27 -05:00
}
)//my w
}
}
2023-12-17 14:55:27 -05:00
// let valid
2023-12-20 11:54:03 -05:00
else if (command.trustLevel === 1){
if(!bot.options.Core.CorelessMode && !source.sources.console){
t_rust.push(`&5${command.name + ' '}`)
}else {
2023-12-17 14:55:27 -05:00
t_rust.push(
{
text: command.name + ' ',
2024-01-12 12:24:01 -05:00
color: 'dark_purple',
2023-12-17 14:55:27 -05:00
translate:"",
hoverEvent:{
action:"show_text",
value:[
{
text:`Command:${command.name}\n`,
color:'white'
2023-12-20 11:54:03 -05:00
}, {text:`Trust Level: `,color:'white'},
{text:`${command.trustLevel}\n`,color:'red'}, {text:`${command.description}\n`, color:'white'},
2023-12-17 14:55:27 -05:00
{text:`Command Aliases: ${command.aliases}\n`,color:'white'},
{text:'click on me to use me :)'},
]
},clickEvent:{
action:"run_command",value:`${bot.options.commands.prefixes[0]}${command.name}`
2023-12-17 14:55:27 -05:00
},
// ${command.name}\nhashOnly:§c${command.hashOnly}§r\nconsoleOnly:§c${command.consoleOnly && !context.console}§r\n${command.description}
///tellraw @a {"translate":"","hoverEvent":{"action":"show_text","value":[{"text":""},{"text":""}]},"clickEvent":{"action":"run_command","value":"a"}}
// clickEvent: command.name ? { action: 'suggest_command', value: `~${command.name}` },
}
)
}
2023-12-17 14:55:27 -05:00
//my w
}
2023-12-20 11:54:03 -05:00
else if (command.trustLevel === 0){
if (!bot.options.Core.CorelessMode && !source.sources.console){
pub_lick.push(`&b${command.name + ' '}`)
} else{
pub_lick.push(
2023-12-17 14:55:27 -05:00
{
text: command.name + ' ',
2024-01-12 12:24:01 -05:00
color: '#00FFFF',
2023-12-17 14:55:27 -05:00
translate:"",
hoverEvent:{
action:"show_text", // Welcome to Kaboom!\n > Free OP - Anarchy - Creative (frfr)
value:[
{
text:`Command:${command.name}\n`,
color:'white'
},{
2023-12-24 12:11:42 -05:00
text:`Trust Level: `,color:'white'},
2023-12-20 11:54:03 -05:00
{text:`${command.trustLevel}\n`,color:'red'},
2023-12-17 14:55:27 -05:00
{text:`${command.description}\n`, color:'white'},
{text:`Command Aliases: ${command.aliases}\n`,color:'white'},
{text:'click on me to use me :)'},
]
},clickEvent:{
action:"suggest_command",value:`${bot.options.commands.prefixes[0]}${command.name}`}
2023-12-17 14:55:27 -05:00
})
2023-12-17 14:55:27 -05:00
}
}
}
function sleep(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
2023-12-17 14:55:27 -05:00
// Use the sleep function with async/await
/*async function main() {
console.log("Before sleep");
await sleep(1000); // Wait for one second
console.log("After sleep");
}
*/
2023-12-17 14:55:27 -05:00
const isConsole = context.source.player ? false : true
if(source.sources.console) {
2023-12-17 14:55:27 -05:00
// mabe idk
2024-01-12 12:24:01 -05:00
const length = context.bot.commandManager.commandlist.length
2023-12-17 14:55:27 -05:00
bot.console.info(bot.getMessageAsPrismarine([cmd, 'Commands (', length, ') ', category, ...pub_lick, t_rust, own_her, cons_ole])?.toAnsi(), false)//[cmd, 'Commands (', length, ') ', category, ...pub_lick, t_rust, own_her, cons_ole]
} else if (!bot.options.Core.CorelessMode) {
const length = context.bot.commandManager.commandlist.filter(c => c.trustLevel != 3).length
bot.chat('Commands (' + length + ') (&bPublic &f| &5Trusted &f| &4Owner&f)')
await sleep(1000)
bot.chat(`${pub_lick}`)
await sleep(1000)
bot.chat(`${t_rust}`)
await sleep(1000)
bot.chat(`${own_her}`)
}else {//+ t_rust + own_her
2024-01-12 12:24:01 -05:00
const length = context.bot.commandManager.commandlist.filter(c => c.trustLevel != 3).length
2023-12-20 11:54:03 -05:00
//trustlevel
source.sendFeedback([cmd, 'Commands (', JSON.stringify(length), ') ', category, ...pub_lick, t_rust ,own_her], false)
}
// bot.
/*
bot.tellraw([pub_lick])
bot.tellraw([t_rust])
bot.tellraw([own_her])
*/
2023-12-17 14:55:27 -05:00
//console.log(t_rust)
}//
}
}