hash check in commands plugin and change servereval description

This commit is contained in:
ChomeNS 2022-11-23 16:24:00 +07:00
parent a15a529103
commit 90b7d09650
11 changed files with 59 additions and 88 deletions

View file

@ -6,11 +6,7 @@ module.exports = {
trusted: 1, trusted: 1,
usage: '<hash> <c:|command>', usage: '<hash> <c:|command>',
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { 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(' ')}`);
bot.core.run(`essentials:sudo * ${args.slice(1).join(' ')}`);
} else {
throw new Error('Invalid hash');
}
}, },
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) { discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {
if (message.member.roles.cache.some((role) => role.name === 'Trusted')) { if (message.member.roles.cache.some((role) => role.name === 'Trusted')) {

View file

@ -11,27 +11,23 @@ module.exports = {
], ],
trusted: 1, trusted: 1,
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
if (args[0] === hash) { if (args[1] === 'true' || args[1] === 'on') {
if (args[1] === 'true' || args[1] === 'on') { bot.visibility = true;
bot.visibility = true; bot.chat('/essentials:vanish disable');
bot.chat('/essentials:vanish disable'); bot.tellraw(selector, [{text: 'The bot\'s visibility is now ', color: 'white'}, {text: 'visible', color: 'green'}]);
bot.tellraw(selector, [{text: 'The bot\'s visibility is now ', color: 'white'}, {text: 'visible', color: 'green'}]); } else if (args[1] === 'false' || args[1] === 'off') {
} else if (args[1] === 'false' || args[1] === 'off') { bot.visibility = false;
bot.visibility = false; bot.chat('/essentials:vanish enable');
bot.chat('/essentials:vanish enable'); bot.tellraw(selector, [{text: 'The bot\'s visibility is now ', color: 'white'}, {text: 'invisible', color: 'gold'}]);
bot.tellraw(selector, [{text: 'The bot\'s visibility is now ', color: 'white'}, {text: 'invisible', color: 'gold'}]); } else if (!args[1]) {
} else if (!args[1]) { bot.visibility = !bot.visibility;
bot.visibility = !bot.visibility; const greenOrGold = bot.visibility ? 'green' : 'gold';
const greenOrGold = bot.visibility ? 'green' : 'gold'; const visibleOrInvisible = bot.visibility ? 'visible' : 'invisible';
const visibleOrInvisible = bot.visibility ? 'visible' : 'invisible'; const enableOrDisable = bot.visibility ? 'disable' : 'enable';
const enableOrDisable = bot.visibility ? 'disable' : 'enable'; bot.chat(`/essentials:vanish ${enableOrDisable}`);
bot.chat(`/essentials:vanish ${enableOrDisable}`); bot.tellraw(selector, [{text: 'The bot\'s visibility is now ', color: 'white'}, {text: visibleOrInvisible, color: greenOrGold}]);
bot.tellraw(selector, [{text: 'The bot\'s visibility is now ', color: 'white'}, {text: visibleOrInvisible, color: greenOrGold}]);
} else {
throw new SyntaxError('Invalid argument');
}
} else { } else {
throw new Error('Invalid hash'); throw new SyntaxError('Invalid argument');
} }
}, },
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) { discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {

View file

@ -68,25 +68,20 @@ module.exports = {
trusted: 1, trusted: 1,
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
if (!bot.cloops) bot.cloops = []; if (!bot.cloops) bot.cloops = [];
if (args[1] === 'add' && args[3]) {
if (args[0] === hash) { if (!Number(args[2]) && Number(args[2]) !== 0) throw new SyntaxError('Invalid interval');
if (args[1] === 'add' && args[3]) { add(args.slice(3).join(' '), args[2], bot);
if (!Number(args[2]) && Number(args[2]) !== 0) throw new SyntaxError('Invalid interval'); 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'}]);
add(args.slice(3).join(' '), args[2], bot); } else if (args[1] === 'list') {
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'}]); list(bot, false, null, selector);
} else if (args[1] === 'list') { } else if (args[1] === 'remove') {
list(bot, false, null, selector); remove(args[2], bot);
} else if (args[1] === 'remove') { bot.tellraw(selector, [{text: 'Removed cloop '}, {text: args[2], color: 'aqua'}]);
remove(args[2], bot); } else if (args[1] === 'removeall') {
bot.tellraw(selector, [{text: 'Removed cloop '}, {text: args[2], color: 'aqua'}]); clear(bot);
} else if (args[1] === 'removeall') { bot.tellraw(selector, [{text: 'Removed all looped commands', color: 'white'}]);
clear(bot);
bot.tellraw(selector, [{text: 'Removed all looped commands', color: 'white'}]);
} else {
throw new SyntaxError('Invalid argument');
}
} else { } else {
throw new Error('Invalid hash'); throw new SyntaxError('Invalid argument');
} }
}, },
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) { discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {

View file

@ -20,11 +20,9 @@ module.exports = {
usage: '<hash>', usage: '<hash>',
trusted: 1, trusted: 1,
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
if (args[0] === hash) {
crash(bot); crash(bot);
} else {
throw new Error('Invalid hash');
}
}, },
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) { discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {
if (message.member.roles.cache.some((role) => role.name === 'Trusted')) { if (message.member.roles.cache.some((role) => role.name === 'Trusted')) {

View file

@ -7,24 +7,16 @@ module.exports = {
trusted: 1, trusted: 1,
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
if (args[1] === 'on') { if (args[1] === 'on') {
if (args[0] === hash) { bot.eaglercrashstarted = true;
bot.eaglercrashstarted = true; bot.eaglercrash = setInterval(async function() {
bot.eaglercrash = setInterval(async function() { if (bot.eaglercrashstarted === true) return bot.core.run('minecraft:playsound block.note_block.harp record @a ~ ~ ~ 100000000000000000000000000000000000000 1 0');
if (bot.eaglercrashstarted === true) return bot.core.run('minecraft:playsound block.note_block.harp record @a ~ ~ ~ 100000000000000000000000000000000000000 1 0'); }, 0);
}, 0); bot.core.run('minecraft:tellraw @a ["",{"text":"Eaglercrash started","color":"white"}]');
bot.core.run('minecraft:tellraw @a ["",{"text":"Eaglercrash started","color":"white"}]');
} else {
throw new Error('Invalid hash');
}
} }
if (args[1] === 'off') { if (args[1] === 'off') {
if (args[0] === hash) { clearInterval(bot.eaglercrash);
clearInterval(bot.eaglercrash); bot.eaglercrashstarted = false;
bot.eaglercrashstarted = false; bot.core.run('minecraft:tellraw @a ["",{"text":"Eaglercrash stopped","color":"white"}]');
bot.core.run('minecraft:tellraw @a ["",{"text":"Eaglercrash stopped","color":"white"}]');
} else {
throw new Error('Invalid hash');
}
} }
}, },
}; };

View file

@ -6,11 +6,9 @@ module.exports = {
usage: '<hash>', usage: '<hash>',
trusted: 1, trusted: 1,
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
if (args[0] === hash) {
bot.end('end command'); bot.end('end command');
} else {
throw new Error('Invalid hash');
}
}, },
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) { discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {
if (message.member.roles.cache.some((role) => role.name === 'Trusted')) { if (message.member.roles.cache.some((role) => role.name === 'Trusted')) {

View file

@ -6,10 +6,8 @@ module.exports = {
usage: '<hash> <command>', usage: '<hash> <command>',
trusted: 1, trusted: 1,
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { 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(' ')); bot.core.run('minecraft:execute unless entity @s[name= run ] run ' + args.slice(1).join(' '));
} else {
throw new Error('Invalid hash');
}
}, },
}; };

View file

@ -6,10 +6,8 @@ module.exports = {
usage: '<hash> <gamemode>', usage: '<hash> <gamemode>',
trusted: 1, trusted: 1,
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { 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}]`); bot.core.run(`minecraft:execute unless entity @s[name= run ] run gamemode ${args[1]} @a[name=!${bot.username}]`);
} else {
throw new Error('Invalid hash');
}
}, },
}; };

View file

@ -4,18 +4,14 @@ const {stylize} = require('../util/colors/minecraft');
module.exports = { module.exports = {
name: 'servereval', name: 'servereval',
alias: [], alias: [],
description: 'Eval command without vm2', description: 'Basically eval command but without vm2',
trusted: 2, trusted: 2,
usage: '<ownerhash> <code>', usage: '<ownerhash> <code>',
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) {
if (args[0] === ownerhash) { try {
try { bot.tellraw(selector, {text: `${util.inspect(eval(args.slice(1).join(' ')), {stylize: stylize})}`.substring(0, 32000)});
bot.tellraw(selector, {text: `${util.inspect(eval(args.slice(1).join(' ')), {stylize: stylize})}`.substring(0, 32000)}); } catch (err) {
} catch (err) { bot.tellraw(selector, {text: `${util.inspect(err).replaceAll('runner', 'chayapak1')}`, color: 'red'});
bot.tellraw(selector, {text: `${util.inspect(err).replaceAll('runner', 'chayapak1')}`, color: 'red'});
}
} else {
throw new Error('Invalid OwnerHash');
} }
}, },
}; };

View file

@ -6,10 +6,8 @@ module.exports = {
usage: '<hash> <player>', usage: '<hash> <player>',
trusted: 1, trusted: 1,
execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash, selector) { 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(' ')}`); bot.core.run(`minecraft:execute unless entity @s[name= run ] run tp @a ${args.slice(1).join(' ')}`);
} else {
throw new Error('Invalid hash');
}
}, },
}; };

View file

@ -24,6 +24,12 @@ function inject(bot, dcclient, config) {
if (prefix === '*' && message.endsWith('*') && message !== '*') return; if (prefix === '*' && message.endsWith('*') && message !== '*') return;
if (!command) throw new Error(`Unknown command: "${commandName}"`); 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 (prefix === config.discord.prefix) {
if (typeof command.discordExecute === 'undefined') throw new Error('This command is not yet supported on discord!'); 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); command.discordExecute(bot, username, usernameraw, sender, prefix, args, channeldc, message, config);