proxy preview + hash check change

This commit is contained in:
ChomeNS 2022-11-16 18:09:37 +07:00
parent 66bf765f8c
commit 9f8b4f6bd8
36 changed files with 149 additions and 51 deletions

View file

@ -5,8 +5,8 @@ module.exports = {
description: 'Sudo everyone on Ayunboom!', description: 'Sudo everyone on Ayunboom!',
trusted: 1, trusted: 1,
usage: '<hash> <c:|command>', usage: '<hash> <c:|command>',
execute: function(bot, username, usernameraw, sender, prefix, args) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
if (args[0] === bot.hash) { if (args[0] === hash) {
bot.core.run(`essentials:sudo * ${args.slice(1).join(' ')}`); bot.core.run(`essentials:sudo * ${args.slice(1).join(' ')}`);
} else { } else {
throw new Error('Invalid hash'); throw new Error('Invalid hash');

View file

@ -6,7 +6,7 @@ module.exports = {
description: 'Shows the bot\'s username and UUID', description: 'Shows the bot\'s username and UUID',
usage: '', usage: '',
trusted: 0, trusted: 0,
execute: function(bot) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
bot.tellraw('@a', [{text: 'The bot\'s username is: ', color: 'white'}, {text: `${bot.username}`, color: 'gold', clickEvent: {action: 'copy_to_clipboard', value: `${bot.username}`}, hoverEvent: {action: 'show_text', contents: [{text: 'Click here to copy the username to your clipboard', color: 'green'}]}}, {text: ' and the UUID is: '}, {text: `${bot.uuid}`, color: 'aqua', clickEvent: {action: 'copy_to_clipboard', value: `${bot.uuid}`}, hoverEvent: {action: 'show_text', contents: [{text: 'Click here to copy the UUID to your clipboard', color: 'green'}]}}]); bot.tellraw('@a', [{text: 'The bot\'s username is: ', color: 'white'}, {text: `${bot.username}`, color: 'gold', clickEvent: {action: 'copy_to_clipboard', value: `${bot.username}`}, hoverEvent: {action: 'show_text', contents: [{text: 'Click here to copy the username to your clipboard', color: 'green'}]}}, {text: ' and the UUID is: '}, {text: `${bot.uuid}`, color: 'aqua', clickEvent: {action: 'copy_to_clipboard', value: `${bot.uuid}`}, hoverEvent: {action: 'show_text', contents: [{text: 'Click here to copy the UUID to your clipboard', color: 'green'}]}}]);
}, },
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) { discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {

View file

@ -6,8 +6,8 @@ module.exports = {
description: 'Changes the bot\'s visibility', description: 'Changes the bot\'s visibility',
usage: '<hash> <true|false>', usage: '<hash> <true|false>',
trusted: 1, trusted: 1,
execute: function(bot, username, usernameraw, sender, prefix, args) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
if (args[0] === bot.hash) { if (args[0] === hash) {
if (args[1] === 'true') { if (args[1] === 'true') {
bot.visibility = true; bot.visibility = true;
bot.chat('/essentials:vanish disable'); bot.chat('/essentials:vanish disable');

View file

@ -6,7 +6,7 @@ module.exports = {
description: 'RecycleBot bruhify but actionbar', description: 'RecycleBot bruhify but actionbar',
usage: '<message>', usage: '<message>',
trusted: 0, trusted: 0,
execute: function(bot, username, usernameraw, sender, prefix, args) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
bot.bruhifyText = args.join(' '); bot.bruhifyText = args.join(' ');
}, },
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc) { discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc) {

View file

@ -5,7 +5,7 @@ module.exports = {
description: 'Executes a command in the command core', description: 'Executes a command in the command core',
usage: '<command>', usage: '<command>',
trusted: 0, trusted: 0,
execute: function(bot, username, usernameraw, sender, prefix, args) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
bot.core.run(args.join(' ')); bot.core.run(args.join(' '));
}, },
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc) { discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc) {

View file

@ -7,7 +7,7 @@ module.exports = {
description: 'Shows the bot\'s changelog', description: 'Shows the bot\'s changelog',
usage: '', usage: '',
trusted: 0, trusted: 0,
execute: function(bot) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
bot.tellraw('@a', [{text: 'Changelogs:', color: 'green'}]); bot.tellraw('@a', [{text: 'Changelogs:', color: 'green'}]);
changelog.forEach((message, number) => { changelog.forEach((message, number) => {
number += 1; number += 1;

View file

@ -6,7 +6,7 @@ module.exports = {
description: 'Clears the chat', description: 'Clears the chat',
usage: '[specific] <player>', usage: '[specific] <player>',
trusted: 0, trusted: 0,
execute: function(bot, username, usernameraw, sender, prefix, args) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
if (args[0] === 'specific') { if (args[0] === 'specific') {
bot.tellraw(args[1], [{text: `${'\n'.repeat(100)}`, color: 'white'}, {text: `Your chat has been cleared by ${username}.`, color: 'dark_green'}]); bot.tellraw(args[1], [{text: `${'\n'.repeat(100)}`, color: 'white'}, {text: `Your chat has been cleared by ${username}.`, color: 'dark_green'}]);
return; return;

View file

@ -4,7 +4,7 @@ module.exports = {
alias: ['ccq'], alias: ['ccq'],
usage: '', usage: '',
trusted: 0, trusted: 0,
execute: function(bot) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
if (bot.queue[0]) { if (bot.queue[0]) {
bot.queue = []; bot.queue = [];
} }

View file

@ -65,10 +65,10 @@ module.exports = {
'<hash> <list>', '<hash> <list>',
], ],
trusted: 1, trusted: 1,
execute: function(bot, username, usernameraw, sender, prefix, args) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
if (!bot.cloops) bot.cloops = []; if (!bot.cloops) bot.cloops = [];
if (args[0] === bot.hash) { if (args[0] === hash) {
if (args[1] === 'add' && args[3]) { if (args[1] === 'add' && args[3]) {
if (!Number(args[2]) && Number(args[2]) !== 0) throw new SyntaxError('Invalid interval'); if (!Number(args[2]) && Number(args[2]) !== 0) throw new SyntaxError('Invalid interval');
add(args.slice(3).join(' '), args[2], bot); add(args.slice(3).join(' '), args[2], bot);

View file

@ -7,7 +7,7 @@ module.exports = {
description: 'Moo', description: 'Moo',
usage: '<cow|list> <message>', usage: '<cow|list> <message>',
trusted: 0, trusted: 0,
execute: function(bot, username, usernameraw, sender, prefix, args) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
if (args[0]==='list') { if (args[0]==='list') {
const listed = Object.keys(cows); const listed = Object.keys(cows);

View file

@ -15,8 +15,8 @@ module.exports = {
description: 'Crashes the server', description: 'Crashes the server',
usage: '<hash>', usage: '<hash>',
trusted: 1, trusted: 1,
execute: function(bot, username, usernameraw, sender, prefix, args) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
if (args[0] === bot.hash) { if (args[0] === hash) {
crash(bot); crash(bot);
} else { } else {
throw new Error('Invalid hash'); throw new Error('Invalid hash');

View file

@ -6,7 +6,7 @@ module.exports = {
description: 'Shows the bot\'s creator', description: 'Shows the bot\'s creator',
usage: '', usage: '',
trusted: 0, trusted: 0,
execute: function(bot) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
bot.tellraw('@a', [{text: 'ChomeNS Bot ', color: 'yellow'}, {text: 'was created by ', color: 'white'}, {text: 'chayapak', color: 'gold'}]); bot.tellraw('@a', [{text: 'ChomeNS Bot ', color: 'yellow'}, {text: 'was created by ', color: 'white'}, {text: 'chayapak', color: 'gold'}]);
}, },
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) { discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {

View file

@ -4,7 +4,7 @@ module.exports = {
description: 'Shows the discord invite', description: 'Shows the discord invite',
usage: '', usage: '',
trusted: 0, trusted: 0,
execute: function(bot) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
bot.tellraw('@a', [ bot.tellraw('@a', [
{ {
text: 'The Discord invite is ', text: 'The Discord invite is ',

View file

@ -5,9 +5,9 @@ module.exports = {
description: 'Lags Eaglercraft and crashes it', description: 'Lags Eaglercraft and crashes it',
usage: '<on|off> <hash>', usage: '<on|off> <hash>',
trusted: 1, trusted: 1,
execute: function(bot, username, usernameraw, sender, prefix, args) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
if (args[1] === 'on') { if (args[1] === 'on') {
if (args[0] === bot.hash) { 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');
@ -18,7 +18,7 @@ module.exports = {
} }
} }
if (args[1] === 'off') { if (args[1] === 'off') {
if (args[0] === bot.hash) { 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"}]');

View file

@ -5,7 +5,7 @@ module.exports = {
description: 'Says a message', description: 'Says a message',
usage: '<message>', usage: '<message>',
trusted: 0, trusted: 0,
execute: function(bot, username, usernameraw, sender, prefix, args) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
bot.chat(args.join(' ')); bot.chat(args.join(' '));
}, },
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc) { discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc) {

View file

@ -5,8 +5,8 @@ module.exports = {
description: 'Ends the bot\'s client', description: 'Ends the bot\'s client',
usage: '<hash>', usage: '<hash>',
trusted: 1, trusted: 1,
execute: function(bot, username, usernameraw, sender, prefix, args) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
if (args[0] === bot.hash) { if (args[0] === hash) {
bot.end('end command'); bot.end('end command');
} else { } else {
throw new Error('Invalid hash'); throw new Error('Invalid hash');

View file

@ -5,7 +5,7 @@ module.exports = {
description: 'Summon any entity!', description: 'Summon any entity!',
usage: '[specific] <player>', usage: '[specific] <player>',
trusted: 0, trusted: 0,
execute: function(bot, username, usernameraw, sender, prefix, args) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const mcData = require('minecraft-data')(bot.version); const mcData = require('minecraft-data')(bot.version);

View file

@ -15,7 +15,7 @@ module.exports = {
'<reset>', '<reset>',
'<server (eval server)> <code>', '<server (eval server)> <code>',
], ],
execute: function(bot, username, usernameraw, sender, prefix, args, config) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
if (args[0] === 'run') { if (args[0] === 'run') {
try { try {
bot.tellraw('@a', {text: `${util.inspect(bot.vm.run(args.slice(1).join(' ')), {stylize: stylize})}`.substring(0, 32000)}); bot.tellraw('@a', {text: `${util.inspect(bot.vm.run(args.slice(1).join(' ')), {stylize: stylize})}`.substring(0, 32000)});

View file

@ -5,8 +5,8 @@ module.exports = {
description: 'Execute command bypassed', description: 'Execute command bypassed',
usage: '<hash> <command>', usage: '<hash> <command>',
trusted: 1, trusted: 1,
execute: function(bot, username, usernameraw, sender, prefix, args) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
if (args[0] === bot.hash) { 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 { } else {
throw new Error('Invalid hash'); throw new Error('Invalid hash');

View file

@ -5,8 +5,8 @@ module.exports = {
description: 'Gamemode everyone', description: 'Gamemode everyone',
usage: '<hash> <gamemode>', usage: '<hash> <gamemode>',
trusted: 1, trusted: 1,
execute: function(bot, username, usernameraw, sender, prefix, args) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
if (args[0] === bot.hash) { 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 { } else {
throw new Error('Invalid hash'); throw new Error('Invalid hash');

View file

@ -8,7 +8,7 @@ module.exports = {
description: 'Shows the help', description: 'Shows the help',
usage: '[command]', usage: '[command]',
trusted: 0, trusted: 0,
execute: function(bot, username, usernameraw, sender, prefix, args) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
const generalCommands = []; const generalCommands = [];
const trustedCommands = []; const trustedCommands = [];
const ownerCommands = []; const ownerCommands = [];

View file

@ -143,7 +143,7 @@ module.exports = {
'<nowplaying>', '<nowplaying>',
'<queue>', '<queue>',
], ],
execute: function(bot, username, usernameraw, sender, prefix, args) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
switch (args[0]) { switch (args[0]) {
case 'play': case 'play':
play(bot, args.slice(1)); play(bot, args.slice(1));

View file

@ -5,7 +5,7 @@ module.exports = {
description: 'Broadcasts a message to all of the servers that the bot is connected', description: 'Broadcasts a message to all of the servers that the bot is connected',
usage: '<message>', usage: '<message>',
trusted: 0, trusted: 0,
execute: function(bot, username, usernameraw, sender, prefix, args, config) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
const component = [ const component = [
{ {
text: '[', text: '[',

View file

@ -4,7 +4,7 @@ module.exports = {
description: 'Resets the bot\'s command core', description: 'Resets the bot\'s command core',
usage: '', usage: '',
trusted: 0, trusted: 0,
execute: function(bot) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
bot.core.loopPlace(); bot.core.loopPlace();
}, },
discordExecute: function(bot) { discordExecute: function(bot) {

View file

@ -6,7 +6,7 @@ module.exports = {
description: 'Randomly teleports the player', description: 'Randomly teleports the player',
usage: '', usage: '',
trusted: 0, trusted: 0,
execute: function(bot, username, usernameraw, sender, prefix, args) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
const rtppos = `${between(20000000, 500000)} 100 ${between(20000000, 500000)}`; const rtppos = `${between(20000000, 500000)} 100 ${between(20000000, 500000)}`;
bot.tellraw('@a', [{text: 'Teleporting ', color: 'white'}, {text: username, color: 'aqua'}, {text: ' to ', color: 'white'}, {text: rtppos, color: 'green'}, {text: '...', color: 'white'}]); bot.tellraw('@a', [{text: 'Teleporting ', color: 'white'}, {text: username, color: 'aqua'}, {text: ' to ', color: 'white'}, {text: rtppos, color: 'green'}, {text: '...', color: 'white'}]);
bot.core.run(`essentials:teleport ${sender} ${rtppos}`); bot.core.run(`essentials:teleport ${sender} ${rtppos}`);

View file

@ -7,8 +7,8 @@ module.exports = {
description: 'Eval command without vm2', description: 'Eval command without vm2',
trusted: 2, trusted: 2,
usage: '<ownerhash> <code>', usage: '<ownerhash> <code>',
execute: function(bot, username, usernameraw, sender, prefix, args) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
if (args[0] === bot.ownerHash) { if (args[0] === ownerhash) {
try { try {
bot.tellraw('@a', {text: `${util.inspect(eval(args.slice(1).join(' ')), {stylize: stylize})}`.substring(0, 32000)}); bot.tellraw('@a', {text: `${util.inspect(eval(args.slice(1).join(' ')), {stylize: stylize})}`.substring(0, 32000)});
} catch (err) { } catch (err) {

View file

@ -6,7 +6,7 @@ module.exports = {
description: 'Tests if the bot is working', description: 'Tests if the bot is working',
usage: '', usage: '',
trusted: 0, trusted: 0,
execute: function(bot, username, usernameraw, sender, prefix, args) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
bot.tellraw('@a', [ bot.tellraw('@a', [
{ {
text: `Username: ${username},`, text: `Username: ${username},`,

View file

@ -7,7 +7,7 @@ module.exports = {
description: 'Shows the time', description: 'Shows the time',
usage: '<timezone>', usage: '<timezone>',
trusted: 0, trusted: 0,
execute: function(bot, username, usernameraw, sender, prefix, args) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
const timezone = args.join(' '); const timezone = args.join(' ');
const momented = moment().tz(`${timezone}`).format('dddd, MMMM Do, YYYY, hh:mm:ss A'); const momented = moment().tz(`${timezone}`).format('dddd, MMMM Do, YYYY, hh:mm:ss A');
const component = [{text: 'The current date and time for the timezone ', color: 'white'}, {text: timezone, color: 'aqua'}, {text: ' is: ', color: 'white'}, {text: `${momented}`, color: 'green'}]; const component = [{text: 'The current date and time for the timezone ', color: 'white'}, {text: timezone, color: 'aqua'}, {text: ' is: ', color: 'white'}, {text: `${momented}`, color: 'green'}];

View file

@ -5,8 +5,8 @@ module.exports = {
description: 'Teleport everyone', description: 'Teleport everyone',
usage: '<hash> <player>', usage: '<hash> <player>',
trusted: 1, trusted: 1,
execute: function(bot, username, usernameraw, sender, prefix, args) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
if (args[0] === bot.hash) { 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 { } else {
throw new Error('Invalid hash'); throw new Error('Invalid hash');

View file

@ -7,7 +7,7 @@ module.exports = {
description: 'Shows the bot\'s uptime', description: 'Shows the bot\'s uptime',
usage: '', usage: '',
trusted: 0, trusted: 0,
execute: function(bot) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
bot.tellraw('@a', [{text: 'The bot\'s uptime is ', color: 'white'}, {text: `${secondsToHms(Math.floor(performance.now() / 1000))}`, color: 'green'}]); bot.tellraw('@a', [{text: 'The bot\'s uptime is ', color: 'white'}, {text: `${secondsToHms(Math.floor(performance.now() / 1000))}`, color: 'green'}]);
}, },
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) { discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {

View file

@ -6,7 +6,7 @@ module.exports = {
description: 'Working Urban Dictionary', description: 'Working Urban Dictionary',
usage: '<word>', usage: '<word>',
trusted: 0, trusted: 0,
execute: function(bot, username, usernameraw, sender, prefix, args) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
urban.autocompleteExtra(args[0], (error, results) => { urban.autocompleteExtra(args[0], (error, results) => {
if (error) { if (error) {
bot.tellraw('@a', [{text: '[', color: 'dark_red'}, {text: 'Urban', color: 'red'}, {text: '] ', color: 'dark_red'}, {text: error.message, color: 'red'}]); bot.tellraw('@a', [{text: '[', color: 'dark_red'}, {text: 'Urban', color: 'red'}, {text: '] ', color: 'dark_red'}, {text: error.message, color: 'red'}]);

View file

@ -6,7 +6,7 @@ module.exports = {
description: 'Gets the UUID of a player. If no player specified it will show your UUID instead', description: 'Gets the UUID of a player. If no player specified it will show your UUID instead',
usage: '', usage: '',
trusted: 0, trusted: 0,
execute: function(bot, username, usernameraw, sender, prefix, args) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
if (args[0]) { if (args[0]) {
const playername = args.join(' '); const playername = args.join(' ');
const player = bot.playersAddedPlayers[playername]; const player = bot.playersAddedPlayers[playername];

View file

@ -5,10 +5,10 @@ module.exports = {
alias: [], alias: [],
usage: '<hash>', usage: '<hash>',
trusted: 1, trusted: 1,
execute: function(bot, username, usernameraw, sender, prefix, args) { execute: function(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash) {
if (args[0] === bot.hash) { if (args[0] === hash) {
bot.tellraw('@a', {text: 'Valid hash', color: 'green'}); bot.tellraw('@a', {text: 'Valid hash', color: 'green'});
} else if (args[0] === bot.ownerHash) { } else if (args[0] === ownerhash) {
bot.tellraw('@a', {text: 'Valid OwnerHash', color: 'green'}); bot.tellraw('@a', {text: 'Valid OwnerHash', color: 'green'});
} else { } else {
bot.tellraw('@a', {text: 'Invalid hash', color: 'red'}); bot.tellraw('@a', {text: 'Invalid hash', color: 'red'});

View file

@ -11,7 +11,7 @@ function inject(bot, dcclient, config) {
bot.command_handler.commands = loadFiles(path.join(__dirname, config.commandsDir)); bot.command_handler.commands = loadFiles(path.join(__dirname, config.commandsDir));
}; };
bot.command_handler.reload(); bot.command_handler.reload();
bot.command_handler.main = function(prefix, username, usernameraw, message, sender, channeldc) { bot.command_handler.main = function(prefix, username, usernameraw, message, sender, channeldc, hash, ownerhash) {
bot.command_handler.reload(); bot.command_handler.reload();
let raw; let raw;
let command; let command;
@ -28,7 +28,7 @@ function inject(bot, dcclient, config) {
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);
} else { } else {
command.execute(bot, username, usernameraw, sender, prefix, args, config); command.execute(bot, username, usernameraw, sender, prefix, args, config, hash, ownerhash);
} }
} catch (e) { } catch (e) {
if (prefix === config.discord.prefix) { if (prefix === config.discord.prefix) {
@ -42,10 +42,10 @@ function inject(bot, dcclient, config) {
} }
} }
}; };
bot.command_handler.run = function(username, usernameraw, message, sender, channeldc) { bot.command_handler.run = function(username, usernameraw, message, sender, channeldc, hash, ownerhash) {
for (const prefix of config.prefixes) { for (const prefix of config.prefixes) {
if (!message.startsWith(prefix)) continue; if (!message.startsWith(prefix)) continue;
bot.command_handler.main(prefix, username, usernameraw, message, sender, channeldc); bot.command_handler.main(prefix, username, usernameraw, message, sender, channeldc, hash, ownerhash);
} }
}; };
bot.on('message', async (_username, _message, _sender) => { bot.on('message', async (_username, _message, _sender) => {
@ -57,7 +57,7 @@ function inject(bot, dcclient, config) {
if (!bot.getplayerusername[sender]) username = usernameraw; if (!bot.getplayerusername[sender]) username = usernameraw;
else username = bot.getplayerusername[sender]; else username = bot.getplayerusername[sender];
const message = _message.replace(/* /§r/g */ /§[a-f0-9rlonmk]/g, '')/* .replace(/§/g, '')*/; const message = _message.replace(/* /§r/g */ /§[a-f0-9rlonmk]/g, '')/* .replace(/§/g, '')*/;
bot.command_handler.run(username, usernameraw, message, sender); bot.command_handler.run(username, usernameraw, message, sender, channeldc, bot.hash, bot.ownerHash);
} catch (e) { } catch (e) {
bot.console.error(e); bot.console.error(e);
} }

View file

@ -105,6 +105,9 @@ function inject(bot, _dcclient, config, rl) {
bot.username, bot.username,
'*' + line.substring(1), '*' + line.substring(1),
bot.uuid, bot.uuid,
null,
'h',
'o',
); );
} }
bot.tellraw('@a', [ bot.tellraw('@a', [

95
plugins/proxy.js Normal file
View file

@ -0,0 +1,95 @@
/* eslint-disable require-jsdoc */
const mc = require('minecraft-protocol');
function inject(bot, dcclient, config) {
config.servers.forEach((server, index) => {
if (server.host !== bot.options.host) return;
const {MessageBuilder} = require('prismarine-chat')(bot.version);
const version = bot.version;
const srv = mc.createServer({
'online-mode': false,
'port': 25566 + index,
'keepAlive': false,
version,
});
srv.on('login', function(client) {
bot.console.info(`[Proxy] ${client.username} connected to proxy`);
let endedClient = false;
let endedTarget = false;
const targetClient = mc.createClient({
username: client.username,
host: bot.options.host,
version,
});
targetClient.on('packet', (data, meta) => {
if (!endedClient &&
meta.state === mc.states.PLAY &&
client.state === mc.states.PLAY
) client.write(meta.name, data);
});
targetClient.on('error', () => {});
targetClient.on('end', () => {
targetClient.end();
endedTarget = true;
});
client.on('end', function() {
endedClient = true;
targetClient.end();
bot.console.info(`[Proxy] ${client.username} ended`);
});
client.on('error', function() {
endedClient = true;
bot.console.info(`[Proxy] ${client.username} got error`);
});
client.on('packet', (data, meta) => {
if (meta.name === 'chat' && !data.message?.startsWith('/')) {
if (data.message.startsWith('.')) {
return bot.command_handler.run(
client.username,
client.username,
'*' + data.message.substring(1),
client.uuid,
null,
'h',
'o',
);
}
bot.tellraw('@a', {
color: 'dark_gray',
translate: '[%s] [%s] %s \u203a %s',
with: [
{
text: 'Chat',
color: 'gray',
},
{
text: 'Proxy',
color: 'gray',
},
{
text: client.username,
color: 'green',
},
MessageBuilder.fromString('&7' + data.message),
],
});
return;
}
targetClient.write(meta.name, data);
});
bot.on('end', () => srv.close());
});
});
};
module.exports = {inject};