diff --git a/commands/ayunsudo.js b/commands/ayunsudo.js index d79b1f0..edd9aaf 100644 --- a/commands/ayunsudo.js +++ b/commands/ayunsudo.js @@ -6,11 +6,7 @@ module.exports = { trusted: 1, usage: ' ', execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { - if (args[0] === hash) { - bot.core.run(`essentials:sudo * ${args.slice(1).join(' ')}`); - } else { - throw new Error('Invalid hash'); - } + bot.core.run(`essentials:sudo * ${args.slice(1).join(' ')}`); }, discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) { if (message.member.roles.cache.some((role) => role.name === 'Trusted')) { diff --git a/commands/botvisibility.js b/commands/botvisibility.js index 6afd8fe..35293bf 100644 --- a/commands/botvisibility.js +++ b/commands/botvisibility.js @@ -11,27 +11,23 @@ module.exports = { ], trusted: 1, execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { - if (args[0] === hash) { - if (args[1] === 'true' || args[1] === 'on') { - bot.visibility = true; - bot.chat('/essentials:vanish disable'); - bot.tellraw(selector, [{text: 'The bot\'s visibility is now ', color: 'white'}, {text: 'visible', color: 'green'}]); - } else if (args[1] === 'false' || args[1] === 'off') { - bot.visibility = false; - bot.chat('/essentials:vanish enable'); - bot.tellraw(selector, [{text: 'The bot\'s visibility is now ', color: 'white'}, {text: 'invisible', color: 'gold'}]); - } else if (!args[1]) { - bot.visibility = !bot.visibility; - const greenOrGold = bot.visibility ? 'green' : 'gold'; - const visibleOrInvisible = bot.visibility ? 'visible' : 'invisible'; - const enableOrDisable = bot.visibility ? 'disable' : 'enable'; - bot.chat(`/essentials:vanish ${enableOrDisable}`); - bot.tellraw(selector, [{text: 'The bot\'s visibility is now ', color: 'white'}, {text: visibleOrInvisible, color: greenOrGold}]); - } else { - throw new SyntaxError('Invalid argument'); - } + if (args[1] === 'true' || args[1] === 'on') { + bot.visibility = true; + bot.chat('/essentials:vanish disable'); + bot.tellraw(selector, [{text: 'The bot\'s visibility is now ', color: 'white'}, {text: 'visible', color: 'green'}]); + } else if (args[1] === 'false' || args[1] === 'off') { + bot.visibility = false; + bot.chat('/essentials:vanish enable'); + bot.tellraw(selector, [{text: 'The bot\'s visibility is now ', color: 'white'}, {text: 'invisible', color: 'gold'}]); + } else if (!args[1]) { + bot.visibility = !bot.visibility; + const greenOrGold = bot.visibility ? 'green' : 'gold'; + const visibleOrInvisible = bot.visibility ? 'visible' : 'invisible'; + const enableOrDisable = bot.visibility ? 'disable' : 'enable'; + bot.chat(`/essentials:vanish ${enableOrDisable}`); + bot.tellraw(selector, [{text: 'The bot\'s visibility is now ', color: 'white'}, {text: visibleOrInvisible, color: greenOrGold}]); } else { - throw new Error('Invalid hash'); + throw new SyntaxError('Invalid argument'); } }, discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) { diff --git a/commands/cloop.js b/commands/cloop.js index 5f80ecd..fc211a1 100644 --- a/commands/cloop.js +++ b/commands/cloop.js @@ -68,25 +68,20 @@ module.exports = { trusted: 1, execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { if (!bot.cloops) bot.cloops = []; - - if (args[0] === hash) { - if (args[1] === 'add' && args[3]) { - if (!Number(args[2]) && Number(args[2]) !== 0) throw new SyntaxError('Invalid interval'); - add(args.slice(3).join(' '), args[2], bot); - bot.tellraw(selector, [{text: 'Added command ', color: 'white'}, {text: `${args.slice(3).join(' ')}`, color: 'aqua'}, {text: ' with interval ', color: 'white'}, {text: `${args[2]}`, color: 'green'}, {text: ' to the cloops', color: 'white'}]); - } else if (args[1] === 'list') { - list(bot, false, null, selector); - } else if (args[1] === 'remove') { - remove(args[2], bot); - bot.tellraw(selector, [{text: 'Removed cloop '}, {text: args[2], color: 'aqua'}]); - } else if (args[1] === 'removeall') { - clear(bot); - bot.tellraw(selector, [{text: 'Removed all looped commands', color: 'white'}]); - } else { - throw new SyntaxError('Invalid argument'); - } + if (args[1] === 'add' && args[3]) { + if (!Number(args[2]) && Number(args[2]) !== 0) throw new SyntaxError('Invalid interval'); + add(args.slice(3).join(' '), args[2], bot); + bot.tellraw(selector, [{text: 'Added command ', color: 'white'}, {text: `${args.slice(3).join(' ')}`, color: 'aqua'}, {text: ' with interval ', color: 'white'}, {text: `${args[2]}`, color: 'green'}, {text: ' to the cloops', color: 'white'}]); + } else if (args[1] === 'list') { + list(bot, false, null, selector); + } else if (args[1] === 'remove') { + remove(args[2], bot); + bot.tellraw(selector, [{text: 'Removed cloop '}, {text: args[2], color: 'aqua'}]); + } else if (args[1] === 'removeall') { + clear(bot); + bot.tellraw(selector, [{text: 'Removed all looped commands', color: 'white'}]); } else { - throw new Error('Invalid hash'); + throw new SyntaxError('Invalid argument'); } }, discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) { diff --git a/commands/crashserver.js b/commands/crashserver.js index d3fa05e..e6bc9ef 100644 --- a/commands/crashserver.js +++ b/commands/crashserver.js @@ -20,11 +20,9 @@ module.exports = { usage: '', trusted: 1, execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { - if (args[0] === hash) { + crash(bot); - } else { - throw new Error('Invalid hash'); - } + }, discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) { if (message.member.roles.cache.some((role) => role.name === 'Trusted')) { diff --git a/commands/eaglercrash.js b/commands/eaglercrash.js index 1600245..076206d 100644 --- a/commands/eaglercrash.js +++ b/commands/eaglercrash.js @@ -7,24 +7,16 @@ module.exports = { trusted: 1, execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { if (args[1] === 'on') { - if (args[0] === hash) { - bot.eaglercrashstarted = true; - bot.eaglercrash = setInterval(async function() { - if (bot.eaglercrashstarted === true) return bot.core.run('minecraft:playsound block.note_block.harp record @a ~ ~ ~ 100000000000000000000000000000000000000 1 0'); - }, 0); - bot.core.run('minecraft:tellraw @a ["",{"text":"Eaglercrash started","color":"white"}]'); - } else { - throw new Error('Invalid hash'); - } + bot.eaglercrashstarted = true; + bot.eaglercrash = setInterval(async function() { + if (bot.eaglercrashstarted === true) return bot.core.run('minecraft:playsound block.note_block.harp record @a ~ ~ ~ 100000000000000000000000000000000000000 1 0'); + }, 0); + bot.core.run('minecraft:tellraw @a ["",{"text":"Eaglercrash started","color":"white"}]'); } if (args[1] === 'off') { - if (args[0] === hash) { - clearInterval(bot.eaglercrash); - bot.eaglercrashstarted = false; - bot.core.run('minecraft:tellraw @a ["",{"text":"Eaglercrash stopped","color":"white"}]'); - } else { - throw new Error('Invalid hash'); - } + clearInterval(bot.eaglercrash); + bot.eaglercrashstarted = false; + bot.core.run('minecraft:tellraw @a ["",{"text":"Eaglercrash stopped","color":"white"}]'); } }, }; diff --git a/commands/end.js b/commands/end.js index 4f5a1f6..71f7677 100644 --- a/commands/end.js +++ b/commands/end.js @@ -6,11 +6,9 @@ module.exports = { usage: '', trusted: 1, execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { - if (args[0] === hash) { + bot.end('end command'); - } else { - throw new Error('Invalid hash'); - } + }, discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) { if (message.member.roles.cache.some((role) => role.name === 'Trusted')) { diff --git a/commands/executebypass.js b/commands/executebypass.js index 0afe5df..153d933 100644 --- a/commands/executebypass.js +++ b/commands/executebypass.js @@ -6,10 +6,8 @@ module.exports = { usage: ' ', trusted: 1, execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { - if (args[0] === hash) { + bot.core.run('minecraft:execute unless entity @s[name= run ] run ' + args.slice(1).join(' ')); - } else { - throw new Error('Invalid hash'); - } + }, }; diff --git a/commands/gamemodeall.js b/commands/gamemodeall.js index e68d2f8..ad4c122 100644 --- a/commands/gamemodeall.js +++ b/commands/gamemodeall.js @@ -6,10 +6,8 @@ module.exports = { usage: ' ', trusted: 1, execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { - if (args[0] === hash) { + bot.core.run(`minecraft:execute unless entity @s[name= run ] run gamemode ${args[1]} @a[name=!${bot.username}]`); - } else { - throw new Error('Invalid hash'); - } + }, }; diff --git a/commands/servereval.js b/commands/servereval.js index 96ddebf..1fa2316 100644 --- a/commands/servereval.js +++ b/commands/servereval.js @@ -4,18 +4,14 @@ const {stylize} = require('../util/colors/minecraft'); module.exports = { name: 'servereval', alias: [], - description: 'Eval command without vm2', + description: 'Basically eval command but without vm2', trusted: 2, usage: ' ', execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { - if (args[0] === ownerhash) { - try { - bot.tellraw(selector, {text: `${util.inspect(eval(args.slice(1).join(' ')), {stylize: stylize})}`.substring(0, 32000)}); - } catch (err) { - bot.tellraw(selector, {text: `${util.inspect(err).replaceAll('runner', 'chayapak1')}`, color: 'red'}); - } - } else { - throw new Error('Invalid OwnerHash'); + try { + bot.tellraw(selector, {text: `${util.inspect(eval(args.slice(1).join(' ')), {stylize: stylize})}`.substring(0, 32000)}); + } catch (err) { + bot.tellraw(selector, {text: `${util.inspect(err).replaceAll('runner', 'chayapak1')}`, color: 'red'}); } }, }; diff --git a/commands/tpall.js b/commands/tpall.js index 5110ac2..0bb825b 100644 --- a/commands/tpall.js +++ b/commands/tpall.js @@ -6,10 +6,8 @@ module.exports = { usage: ' ', trusted: 1, execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { - if (args[0] === hash) { + bot.core.run(`minecraft:execute unless entity @s[name= run ] run tp @a ${args.slice(1).join(' ')}`); - } else { - throw new Error('Invalid hash'); - } + }, }; diff --git a/plugins/commands.js b/plugins/commands.js index d33704b..4249f1c 100644 --- a/plugins/commands.js +++ b/plugins/commands.js @@ -24,6 +24,12 @@ function inject(bot, dcclient, config) { if (prefix === '*' && message.endsWith('*') && message !== '*') return; if (!command) throw new Error(`Unknown command: "${commandName}"`); + if (command.trusted === 1) { + if (args[0] !== hash) throw new Error('Invalid hash'); + } else if (command.trusted === 2) { + if (args[0] !== ownerhash) throw new Error('Invalid OwnerHash'); + } + if (prefix === config.discord.prefix) { if (typeof command.discordExecute === 'undefined') throw new Error('This command is not yet supported on discord!'); command.discordExecute(bot, username, usernameraw, sender, prefix, args, channeldc, message, config);