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,
usage: '<hash> <c:|command>',
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');
}
},
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {
if (message.member.roles.cache.some((role) => role.name === 'Trusted')) {

View file

@ -11,7 +11,6 @@ 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');
@ -30,9 +29,6 @@ module.exports = {
} else {
throw new SyntaxError('Invalid argument');
}
} 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')) {

View file

@ -68,8 +68,6 @@ 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);
@ -85,9 +83,6 @@ module.exports = {
} else {
throw new SyntaxError('Invalid argument');
}
} else {
throw new Error('Invalid hash');
}
},
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {
if (!bot.cloops) bot.cloops = [];

View file

@ -20,11 +20,9 @@ module.exports = {
usage: '<hash>',
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')) {

View file

@ -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');
}
}
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');
}
}
},
};

View file

@ -6,11 +6,9 @@ module.exports = {
usage: '<hash>',
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')) {

View file

@ -6,10 +6,8 @@ module.exports = {
usage: '<hash> <command>',
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');
}
},
};

View file

@ -6,10 +6,8 @@ module.exports = {
usage: '<hash> <gamemode>',
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');
}
},
};

View file

@ -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: '<ownerhash> <code>',
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');
}
},
};

View file

@ -6,10 +6,8 @@ module.exports = {
usage: '<hash> <player>',
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');
}
},
};

View file

@ -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);