mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-30 10:56:55 -05:00
677 lines
28 KiB
JavaScript
677 lines
28 KiB
JavaScript
/* eslint-disable no-unused-vars */
|
||
/* eslint-disable no-var */
|
||
/* eslint-disable prefer-rest-params */
|
||
/* eslint-disable no-tabs */
|
||
/* eslint-disable max-len */
|
||
/* eslint-disable no-undef */
|
||
const mc = require('minecraft-protocol');
|
||
const config = require('./config');
|
||
const crypto = require('crypto');
|
||
const colorConvert = require('color-convert');
|
||
const chatMessage = require('prismarine-chat')('1.18.2');
|
||
const {containsIllegalCharacters} = require('./util/containsIllegalCharacters');
|
||
const generateEaglerUsername = require('./util/generateEaglerUsername');
|
||
const {EventEmitter} = require('events');
|
||
const fs = require('fs');
|
||
const path = require('path');
|
||
const uuid = require('uuid-by-string');
|
||
const readline = require('node:readline');
|
||
const {stdin: input, stdout: output} = require('node:process');
|
||
const rl = readline.createInterface({input, output});
|
||
const querystring = require('querystring');
|
||
const moment = require('moment-timezone');
|
||
const urban = require('urban-dictionary');
|
||
const cowsay = require('cowsay');
|
||
const {stylize} = require('./util/colors/minecraft');
|
||
const translate = require('@vitalets/google-translate-api');
|
||
const axios = require('axios');
|
||
const util = require('node:util');
|
||
const {between} = require('./util/between');
|
||
const {escapeMarkdown} = require('./util/escapeMarkdown');
|
||
const {VM} = require('vm2');
|
||
const randomstring = require('randomstring');
|
||
const mineflayer = require('mineflayer');
|
||
// readline > fix on console.log
|
||
const log = console.log;
|
||
console.log = function() {
|
||
rl.output.write('\x1b[2K\r');
|
||
log.apply(console, Array.prototype.slice.call(arguments));
|
||
rl._refreshLine();
|
||
};
|
||
|
||
function sleep(ms) {
|
||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||
}
|
||
|
||
// Load discord.js
|
||
const {
|
||
Client,
|
||
Intents,
|
||
MessageEmbed,
|
||
} = require('discord.js');
|
||
// Create Discord intentions, required in v13
|
||
const intents = new Intents(['GUILDS', 'GUILD_MESSAGES']);
|
||
// Create Discord client
|
||
const dcclient = new Client({
|
||
intents,
|
||
});
|
||
|
||
const ayunboomchannel = config.discord.servers['sus.shhnowisnottheti.me:25565'];
|
||
const dinboomchannel = config.discord.servers['129.159.58.114:25565'];
|
||
const kaboomchannel = config.discord.servers['play.kaboom.pw:25565'];
|
||
const localclonechannel = config.discord.servers['192.168.1.103:25565'];
|
||
const kitsunechannel = config.discord.servers['kitsune.icu:25565'];
|
||
let chomenschannel = '969773424387981356';
|
||
const hashchannel = '980438368422871151';
|
||
const ownerhashchannel = '980786390247833620';
|
||
|
||
/**
|
||
* Error
|
||
* @param {*} err
|
||
*/
|
||
// async function onerror(err) {
|
||
// try {
|
||
// console.log(`INFO: Disconnected: ${err}`);
|
||
// fs.appendFileSync('./logs.txt', `INFO: Disconnected: ${err}\r\n`);
|
||
// const Embed = new MessageEmbed()
|
||
// .setColor('#FF0000')
|
||
// .setTitle(`${err.message ?? 'Disconnected'}`)
|
||
// .setDescription(`\`\`\`text\n${err}\`\`\``);
|
||
// channel.send({embeds: [Embed]});
|
||
// if (err.includes('issued "end" command')) {
|
||
// bot.chat('Restarting...');
|
||
// }
|
||
// await sleep(1000);
|
||
// bot.end();
|
||
// bot._client = mc.createClient(bot.options);
|
||
// } catch (e) {
|
||
// return;
|
||
// }
|
||
// }
|
||
|
||
/**
|
||
* empty function for discord message
|
||
* @return {String}
|
||
*/
|
||
function dcmsg() {
|
||
return 'this does nothing...';
|
||
}
|
||
|
||
function botThings() {
|
||
bot = new EventEmitter();
|
||
bot.options = {
|
||
username: `${randomstring.generate(16)}`,
|
||
host: process.argv[2],
|
||
port: process.argv[3] ? Number(process.argv[3]) : 25565,
|
||
version: '1.18.2',
|
||
physicsEnabled: false,
|
||
checkTimeoutInterval: '30000',
|
||
keepAlive: false,
|
||
hideErrors: true,
|
||
};
|
||
bot._client = mc.createClient(bot.options);
|
||
bot.queue = [];
|
||
bot.write = (name, data) => bot._client.write(name, data);
|
||
bot.end = (reason = 'end') => {
|
||
bot.emit('end', reason);
|
||
bot.removeAllListeners();
|
||
bot._client.end();
|
||
bot._client.removeAllListeners();
|
||
};
|
||
bot.visibility = false;
|
||
bot.command_handler = function() {
|
||
return;
|
||
};
|
||
bot.command_handler.commands = {};
|
||
bot.getplayerusername = {};
|
||
|
||
// allink's plugin loader
|
||
const plugins = []; // NOTE: DO NOT CHANGE, PLUGINS ARE LOADED AUTOMATICALLY
|
||
fs.readdirSync(
|
||
path.join(__dirname, 'plugins'),
|
||
).forEach(function(file) { // populate plugins array
|
||
if (file.endsWith('.js')) {
|
||
plugins.push(path.join(__dirname, 'plugins', file));
|
||
}
|
||
});
|
||
plugins.forEach(function(plugin) { // load plugins
|
||
let name = plugin.split('/');
|
||
name = name[name.length - 1];
|
||
try {
|
||
const plug = require(plugin);
|
||
plug.inject(bot, dcclient, config);
|
||
} catch (e) {
|
||
console.log(`Plugin loader: Plugin ${name} is having exception loading the plugin:`);
|
||
console.log(util.inspect(e));
|
||
}
|
||
});
|
||
}
|
||
|
||
/**
|
||
* Main bot function
|
||
*/
|
||
function main() {
|
||
// allink's chat queue
|
||
chatQueue = setInterval(function() {
|
||
try {
|
||
if (bot.queue[0] || bot.queue[0]==='') {
|
||
try {
|
||
if (containsIllegalCharacters(bot.queue[0])) {
|
||
bot.queue.shift();
|
||
return;
|
||
};
|
||
bot.write('chat', {message: bot.queue[0].substring(0, 256)});
|
||
bot.queue.shift();
|
||
} catch (e) {
|
||
console.log(e.message);
|
||
}
|
||
}
|
||
} catch (e) {
|
||
return;
|
||
}
|
||
}, /* funny 555 */ 555);
|
||
|
||
module.exports = function() {
|
||
return bot;
|
||
};
|
||
|
||
dcmsg.queue = '';
|
||
|
||
bot.playersAddedPlayers = {};
|
||
bot.getplayerusername = {};
|
||
|
||
bot.hash = '';
|
||
bot.setHash = function(hash) {
|
||
bot.hash = hash;
|
||
};
|
||
bot.setOwnerHash = function(hash) {
|
||
bot.ownerhash = hash;
|
||
};
|
||
|
||
sleep = (time) => new Promise((a)=>setTimeout(a, time)),
|
||
bot.chat = (message) => {
|
||
bot.queue.push(String(message));
|
||
};
|
||
// fixCmdBlocksOnlyCore=(core)=>{
|
||
// const cmd = `/minecraft:fill ${Math.floor(bot.position.x)} 0 ${Math.floor(bot.position.z)} ${Math.floor(bot.position.x + 15)} 63 ${Math.floor(bot.position.z + 15)} command_block{CustomName: '{"text":"ChomeNS Bot Core","color":"yellow"}'} replace`;
|
||
// if (core===true) {
|
||
// bot.core.run(cmd);
|
||
// } else {
|
||
// bot.chat(cmd);
|
||
// }
|
||
// };
|
||
// fixCmdBlocks=()=>{
|
||
// bot.chat('/essentials:world world');
|
||
// fixCmdBlocksOnlyCore();
|
||
// };
|
||
|
||
discordQueue = setInterval(function() {
|
||
if (dcmsg.queue!='') {
|
||
channel.send(dcmsg.queue.substring(0, 2000));
|
||
dcmsg.queue = '';
|
||
}
|
||
}, 1000);
|
||
|
||
console.log(`Connecting to: ${bot.options.host}:${bot.options.port}...`);
|
||
// fs.appendFileSync('./logs.txt', `\r\Connecting to: ${bot.options.host}:${bot.options.port}...\r\n`);
|
||
channel.send(`Connecting to: \`${bot.options.host}:${bot.options.port}\`...`);
|
||
bot._client.on('login', async function(data) {
|
||
console.log(`Successfully logged in to: ${bot.options.host}:${bot.options.port}`);
|
||
// fs.appendFileSync('./logs.txt', `\r\nSuccessfully logged in to: ${bot.options.host}:${bot.options.port}\r\n`);
|
||
channel.send(`Successfully logged in to: \`${bot.options.host}:${bot.options.port}\``);
|
||
bot.uuid = bot._client.uuid;
|
||
bot.username = bot._client.username;
|
||
bot.entityId = data.entityId;
|
||
previusMessage = undefined;
|
||
loginfinish = false;
|
||
started = false;
|
||
bot.eaglercrashstarted = false;
|
||
await sleep(1500);
|
||
bot.createCore();
|
||
|
||
bot.vmoptions = {
|
||
timeout: 2000,
|
||
sandbox: {
|
||
run: function(cmd) {
|
||
bot.core.run(cmd);
|
||
},
|
||
mc: mc,
|
||
mineflayer: mineflayer,
|
||
chat: bot.chat,
|
||
moment: moment,
|
||
randomstring: randomstring,
|
||
uuid: uuid,
|
||
chatMessage: chatMessage,
|
||
crypto: crypto,
|
||
colorConvert: colorConvert,
|
||
bruhifyText: function(message) {
|
||
if (typeof message!=='string') throw new SyntaxError('message must be a string');
|
||
bot.bruhifyText = message.substring(0, 1000);
|
||
},
|
||
generateEaglerUsername: generateEaglerUsername,
|
||
},
|
||
// require: {
|
||
// mock: {
|
||
// run: run,
|
||
// randomchar: randomchar,
|
||
// chat: bot.chat,
|
||
// mineflayer: mineflayer
|
||
// }
|
||
// }
|
||
};
|
||
bot.vm = new VM(bot.vmoptions);
|
||
|
||
loginfinish = true;
|
||
await sleep(1400);
|
||
bot.core.run('minecraft:tellraw @a ' + JSON.stringify([{text: 'ChomeNS Bot', color: 'yellow'}, {text: ' - a bot made by ', color: 'gray'}, {text: 'chayapak', color: 'gold'}]));
|
||
corefill = setInterval(async function() {
|
||
try {
|
||
bot.core.fillCore(true);
|
||
} catch (e) {
|
||
return;
|
||
}
|
||
}, 2000);
|
||
// NotOnline mode enabled
|
||
notonline = setInterval(async function() {
|
||
fs.readFile('./notonline.txt', 'utf8', (_err, data) => {
|
||
if (data === 'true') {
|
||
bot.core.run('execute run deop chayapak');
|
||
}
|
||
});
|
||
}, 250);
|
||
});
|
||
|
||
bot.on('parsed_chat', async function(message, data) {
|
||
try {
|
||
// prevents command set message and hi % exploit (it uses prismarine-chat)
|
||
const parsedMessage = JSON.parse(data.message);
|
||
if (parsedMessage.translate==='translation.test.invalid') return;
|
||
if (parsedMessage.translate==='advMode.setCommand.success') return;
|
||
|
||
const cleanMessage = escapeMarkdown(message.toString());
|
||
discordMsg = /* '_ _ ' + */cleanMessage.replaceAll('@', '@\u200B').replaceAll('http', '[http]');// .replace(/[\r\n]/gm, '\n')
|
||
|
||
if (previusMessage===message.toString()) return;
|
||
previusMessage = message.toString();
|
||
|
||
console.log(bot.options.host + ': ' + message.toAnsi()/* + '\u001b[0m'*/);
|
||
// fs.appendFileSync('./logs.txt', `${bot.options.host}: ${message.toMotd()}\r\n`);
|
||
// if (discordMsg)return channel.send(`${discordMsg.substring(0, 2000)}`)
|
||
if (message.toMotd().startsWith('§8[§r§eChomeNS §r§9Discord§r§8] §r§c')) return;
|
||
if (message.toString()==='') return;
|
||
if (message.toString().startsWith(' ')) return;
|
||
dcmsg.queue += '\n' + discordMsg.substring(0, 2000);
|
||
} catch (e) {
|
||
return;
|
||
}
|
||
});
|
||
|
||
// bot.on('message', async function(username, message, sender) {
|
||
// try {
|
||
// const usernameraw = username;
|
||
// // let username = usernameraw.replace(/§[a-f0-9rlonmk]/g, "").replace(/§/g, "");
|
||
// const messageraw = message;
|
||
// var username = getplayerusername[sender];
|
||
// var message = messageraw.replace(/§[a-f0-9rlonmk]/g, '').replace(/§/g, '');
|
||
// // if (username===bot.username)return
|
||
// // console.log(username + ': ' + message);
|
||
// allCommands(username, message, usernameraw, sender);
|
||
// } catch (e) {
|
||
// console.log(e);
|
||
// }
|
||
// });
|
||
|
||
// bot.on('cspy', async function(username, message) {
|
||
// // eslint-disable-next-line no-redeclare
|
||
// var username = username.replace(/§[a-f0-9rlonmk]/g, '').replace(/§/g, '');
|
||
// // eslint-disable-next-line no-redeclare
|
||
// var message = message.replace(/§[a-f0-9rlonmk]/g, '').replace(/§/g, '');
|
||
// const args = message.substring(5).trim().split(' ');
|
||
// args[0] = args[0].toLowerCase();
|
||
// try {
|
||
// allCommands(username, message, username, '00000000-0000-0000-0000-000000000000');
|
||
// } catch (e) {
|
||
// bot.core.run('minecraft:tellraw @a ' + JSON.stringify({text: String(e), color: 'red'}));
|
||
// }
|
||
// });
|
||
|
||
bot.on('player_added', (player) => {
|
||
bot.playersAddedPlayers[player.name] = player.UUID;
|
||
bot.getplayerusername[player.UUID] = player.name;
|
||
});
|
||
|
||
bot.on('player_removed', (player) => {
|
||
delete players[player.name];
|
||
});
|
||
|
||
bot._client.on('end', function(reason) {
|
||
bot.emit('end', reason, 'end');
|
||
// onerror('end event: ' + util.inspect(reason).replaceAll('runner', 'chayapak1'));
|
||
});
|
||
|
||
bot._client.on('tab_complete', (packet) => {
|
||
bot.tabcompleteplayers = packet.matches;
|
||
});
|
||
|
||
bot._client.on('kick_disconnect', function(data) {
|
||
const parsed = JSON.parse(data.reason);
|
||
bot.emit('end', parsed, 'kick_disconnect');
|
||
// onerror('kick_disconnect event: ' + util.inspect(reason));
|
||
});
|
||
|
||
bot._client.on('disconnect', function(data) {
|
||
const parsed = JSON.parse(data.reason);
|
||
bot.emit('end', parsed, 'disconnect');
|
||
});
|
||
|
||
bot._client.on('error', function(error) {
|
||
console.log('Error: ' + util.inspect(error));
|
||
channel.send('Error: ' + util.inspect(error));
|
||
// onerror('error event: ' + util.inspect(err).replaceAll('runner', 'chayapak1'));
|
||
});
|
||
|
||
process.on('uncaughtException', (error) => {
|
||
console.log('uncaught ' + util.inspect(error));
|
||
channel.send('uncaught ' + util.inspect(error));
|
||
bot.emit('end', 'uncaughtException');
|
||
});
|
||
|
||
process.on('SIGINT', async function() {
|
||
try {
|
||
bot.chat('Interrupted by console');
|
||
} catch (e) {
|
||
return;
|
||
}
|
||
process.exit();
|
||
});
|
||
|
||
bot.once('end', (reason, event) => {
|
||
console.log(`Disconnected (${event} event): ${util.inspect(reason)}`);
|
||
channel.send(`Disconnected (${event} event): ${util.inspect(reason)}`);
|
||
|
||
let timeout = 3500;
|
||
|
||
try {
|
||
if (reason.text) {
|
||
if (reason.text === 'Wait 5 seconds before connecting, thanks! :)') timeout = 1000 * 6;
|
||
if (reason.text === 'You are logging in too fast, try again later.') timeout = 1000 * 6;
|
||
}
|
||
} catch (e) {
|
||
console.log(e.message);
|
||
}
|
||
|
||
try {
|
||
clearInterval(corefill);
|
||
clearInterval(notonline);
|
||
clearInterval(discordQueue);
|
||
clearInterval(chatQueue);
|
||
} catch (e) {
|
||
return;
|
||
}
|
||
|
||
setTimeout(() => {
|
||
bot.end();
|
||
botThings();
|
||
main();
|
||
}, timeout);
|
||
});
|
||
}
|
||
|
||
dcclient.on('ready', async () => {
|
||
botThings();
|
||
// Find the Discord channel messages will be sent to
|
||
if (process.argv[2]==='sus.shhnowisnottheti.me') {
|
||
channel = dcclient.channels.cache.get(ayunboomchannel);
|
||
bot.channel = dcclient.channels.cache.get(ayunboomchannel);
|
||
}
|
||
if (process.argv[2]==='129.159.58.114') {
|
||
channel = dcclient.channels.cache.get(dinboomchannel);
|
||
bot.channel = dcclient.channels.cache.get(dinboomchannel);
|
||
}
|
||
if (process.argv[2]==='play.kaboom.pw') {
|
||
channel = dcclient.channels.cache.get(kaboomchannel);
|
||
bot.channel = dcclient.channels.cache.get(kaboomchannel);
|
||
}
|
||
if (process.argv[2]==='192.168.1.103') {
|
||
channel = dcclient.channels.cache.get(localclonechannel);
|
||
bot.channel = dcclient.channels.cache.get(localclonechannel);
|
||
}
|
||
if (process.argv[2]==='kitsune.icu') {
|
||
channel = dcclient.channels.cache.get(kitsunechannel);
|
||
bot.channel = dcclient.channels.cache.get(kitsunechannel);
|
||
}
|
||
await sleep(200);
|
||
main();
|
||
chomenschannel = dcclient.channels.cache.get(chomenschannel);
|
||
bot.hashchannel = dcclient.channels.cache.get(hashchannel);
|
||
bot.ownerhashchannel = dcclient.channels.cache.get(ownerhashchannel);
|
||
bot.channelId = channel.id;
|
||
attachmentlink = '';
|
||
|
||
// Console COMMANDS
|
||
rl.on('line', function(line) {
|
||
try {
|
||
const {MessageBuilder} = require('prismarine-chat')('1.18.2');
|
||
if (line.toLowerCase()==='' || line.toLowerCase().startsWith(' ')) return;
|
||
if (line.toLowerCase()==='.exit' || line.toLowerCase()==='.end') {
|
||
bot.emit('end', 'end command');
|
||
// onerror('Console issued "end" command, rebooting bot...');
|
||
return;
|
||
}
|
||
if (line.toLowerCase().startsWith('.servereval ')) {
|
||
try {
|
||
bot.core.run('minecraft:tellraw @a ' + JSON.stringify({text: `${util.inspect(eval(`${line.substring(12)}`))}`, color: 'green'}));
|
||
return;
|
||
} catch (err) {
|
||
bot.core.run('minecraft:tellraw @a ' + JSON.stringify({text: `${util.inspect(err)}`, color: 'red'}));
|
||
return;
|
||
}
|
||
}
|
||
if (line==='.notonline on') {
|
||
fs.writeFileSync('./notonline.txt', 'true');
|
||
return;
|
||
}
|
||
if (line==='.notonline off') {
|
||
fs.writeFileSync('./notonline.txt', 'false');
|
||
return;
|
||
}
|
||
if (line.toLowerCase()==='.resethash') {
|
||
bot.hash = randomstring.generate(16);
|
||
console.log('new hash: ' + bot.hash);
|
||
return;
|
||
}
|
||
// if (line.startsWith("."))return console.log('command not found')
|
||
if (line.startsWith('.')) return bot.command_handler.run('Console', '§e§lConsole§r', '*' + line.substring(1), 'c0ns0le_uuid');
|
||
bot.core.run('minecraft:tellraw @a ' + JSON.stringify(['', {'text': '[', 'color': 'dark_gray'}, {'text': `${bot.username} Console`, 'color': 'gray'}, {'text': '] ', 'color': 'dark_gray'}, {'text': 'chayapak ', 'color': 'green'}, {'text': '› ', 'color': 'dark_gray'}, MessageBuilder.fromString('&7' + line)]));
|
||
} catch (e) {
|
||
console.log(e);
|
||
}
|
||
});
|
||
});
|
||
|
||
// Redirect Discord messages to in-game chat
|
||
dcclient.on('messageCreate', async (message) => {
|
||
// Ignore messages from the bot itself
|
||
if (message.author.id === dcclient.user.id) return;
|
||
const {MessageBuilder} = require('prismarine-chat')('1.18.2');
|
||
const channelid = message.channel.id;
|
||
const channeldc = dcclient.channels.cache.get(channelid);
|
||
// if (message.content.toLowerCase().startsWith('!chomensmsg ')) {
|
||
// bot.core.run(`minecraft:tellraw @a ["",{"text":"[","color":"dark_gray"},{"text":"ChomeNS ","color":"yellow","clickEvent":{"action":"open_url","value":"https://discord.gg/xdgCkUyaA4"},"hoverEvent":{"action":"show_text","contents":[{"text":"https://discord.gg/xdgCkUyaA4 ","color":"blue"},{"text":"<-- join now","color":"red"}]}},{"text":"Discord","color":"blue","clickEvent":{"action":"open_url","value":"https://discord.gg/xdgCkUyaA4"},"hoverEvent":{"action":"show_text","contents":[{"text":"https://discord.gg/xdgCkUyaA4 ","color":"blue"},{"text":"<-- join now","color":"red"}]}},{"text":" (ChomeNS Channel)","color":"gray"},{"text":"] ","color":"dark_gray"},{"text":"${message.member.displayName}","color":"red","clickEvent":{"action":"copy_to_clipboard","value":"${message.author.username}#${message.author.discriminator}"},"hoverEvent":{"action":"show_text","value":{"text":"${message.author.username}§7#${message.author.discriminator}"} }},{"text":" ","color":"white"},` + MessageBuilder.fromString('&7' + message.content.substring(12)) + ']');
|
||
// return;
|
||
// }
|
||
// Only handle messages in specified channel
|
||
if (message.channel.id != channel.id) return;
|
||
if (message.content.startsWith(config.discord.prefix)) return;
|
||
// try {
|
||
// if (message.content.toLowerCase()==='!test') {
|
||
// const Embed = new MessageEmbed()
|
||
// .setColor('#FFFF00')
|
||
// .setTitle('Hello!')
|
||
// .setDescription('This is the first command to be discordified!');
|
||
// channeldc.send({embeds: [Embed]});
|
||
// return;
|
||
// }
|
||
// if (message.content.toLowerCase()==='!help') {
|
||
// const Embed = new MessageEmbed()
|
||
// .setColor('#FFFF00')
|
||
// .setTitle('Commands')
|
||
// .setDescription('help echo cb eval stopserver end ayunsudo playerlist');
|
||
// channeldc.send({embeds: [Embed]});
|
||
// return;
|
||
// }
|
||
// if (message.content.toLowerCase().startsWith('!echo ')) {
|
||
// channeldc.send(`${message.author.username}, sending "${message.content.toLowerCase().substring(6)}"`);
|
||
// bot.chat(message.content.substring(6));
|
||
// return;
|
||
// }
|
||
// if (message.content.toLowerCase().startsWith('!cb ')) {
|
||
// channeldc.send(`${message.author.username}, executing "${message.content.toLowerCase().substring(4)}"`);
|
||
// bot.core.run(message.content.substring(4));
|
||
// return;
|
||
// }
|
||
// if (message.content.toLowerCase().startsWith('!eval run ')) {
|
||
// try {
|
||
// const Embed = new MessageEmbed()
|
||
// .setColor('#FFFF00')
|
||
// .setTitle('Output')
|
||
// .setDescription(`\`\`\`js\n${escapeMarkdown(util.inspect(vm.run(message.content.substring(10))))}\`\`\``.substring(0, 1900));
|
||
// channeldc.send({embeds: [Embed]});
|
||
// } catch (err) {
|
||
// const Embed = new MessageEmbed()
|
||
// .setColor('#FF0000')
|
||
// .setTitle('Error')
|
||
// .setDescription(`\`\`\`text\n${escapeMarkdown(util.inspect(err).replaceAll('runner', 'chayapak1'))}\`\`\``.substring(0, 1900));
|
||
// channeldc.send({embeds: [Embed]});
|
||
// }
|
||
// return;
|
||
// }
|
||
// if (message.content.toLowerCase()==='!eval reset') {
|
||
// vm = new VM(vmoptions);
|
||
// return;
|
||
// }
|
||
// if (message.content.toLowerCase().startsWith('!eval server ')) {
|
||
// axios
|
||
// .post('http://192.168.1.105:4445/', querystring.stringify({
|
||
// html: false,
|
||
// showErrorMsg: true,
|
||
// code: message.content.substring(13),
|
||
// })).then((res) => {
|
||
// const Embed = new MessageEmbed()
|
||
// .setColor('#FFFF00')
|
||
// .setTitle('Output')
|
||
// .setDescription(`\`\`\`js\n${res.data}\`\`\``.substring(0, 1900));
|
||
// channeldc.send({embeds: [Embed]});
|
||
// }).catch((e) => {
|
||
// const Embed = new MessageEmbed()
|
||
// .setColor('#FF0000')
|
||
// .setTitle('Error')
|
||
// .setDescription(`\`\`\`text\n${e}\`\`\``.substring(0, 1900));
|
||
// channeldc.send({embeds: [Embed]});
|
||
// });
|
||
// return;
|
||
// }
|
||
// if (message.content.toLowerCase().startsWith('!eval dineval ')) {
|
||
// axios
|
||
// .get('https://eval.dinhero21.repl.co', {
|
||
// headers: {
|
||
// data: message.content.substring(14),
|
||
// },
|
||
// }).then((res) => {
|
||
// const Embed = new MessageEmbed()
|
||
// .setColor('#FFFF00')
|
||
// .setTitle('Output')
|
||
// .setDescription(`\`\`\`js\n${res.data}\`\`\``.substring(0, 1900));
|
||
// channeldc.send({embeds: [Embed]});
|
||
// }).catch((e) => {
|
||
// const Embed = new MessageEmbed()
|
||
// .setColor('#FF0000')
|
||
// .setTitle('Error')
|
||
// .setDescription(`\`\`\`text\n${e}\`\`\``.substring(0, 1900));
|
||
// channeldc.send({embeds: [Embed]});
|
||
// });
|
||
// return;
|
||
// }
|
||
// if (message.content.toLowerCase()==='!stopserver') {
|
||
// if (message.member._roles.at(0)==='981159334299983953' || message.member._roles.at(0)==='974590495563075594') {
|
||
// bot.core.run('minecraft:execute unless entity @s[name= run ] run stop');
|
||
// } else {
|
||
// const Embed = new MessageEmbed()
|
||
// .setColor('#FF0000')
|
||
// .setTitle('Error')
|
||
// .setDescription('You\'re not in the trusted role!');
|
||
// channeldc.send({embeds: [Embed]});
|
||
// }
|
||
// return;
|
||
// }
|
||
// if (message.content.toLowerCase()==='!end') {
|
||
// if (message.member._roles.at(0)==='981159334299983953' || message.member._roles.at(0)==='974590495563075594') {
|
||
// bot.emit('end', 'end command');
|
||
// // onerror(`${message.member.displayName} issued "end" command, rebooting bot...`);
|
||
// } else {
|
||
// const Embed = new MessageEmbed()
|
||
// .setColor('#FF0000')
|
||
// .setTitle('Error')
|
||
// .setDescription('You\'re not in the trusted role!');
|
||
// channeldc.send({embeds: [Embed]});
|
||
// }
|
||
// return;
|
||
// }
|
||
// if (message.content.toLowerCase().startsWith('!ayunsudo ')) {
|
||
// if (message.member._roles.at(0)==='981159334299983953' || message.member._roles.at(0)==='974590495563075594') {
|
||
// for (const property of bot.players.list) {
|
||
// bot.core.run('sudo ' + property.UUID + ' ' + message.content.toLowerCase().substring(10));
|
||
// }
|
||
// } else {
|
||
// const Embed = new MessageEmbed()
|
||
// .setColor('#FF0000')
|
||
// .setTitle('Error')
|
||
// .setDescription('You\'re not in the trusted role!');
|
||
// channeldc.send({embeds: [Embed]});
|
||
// }
|
||
// return;
|
||
// }
|
||
// if (message.content.toLowerCase()==='!playerlist' || message.content.toLowerCase()==='!list') {
|
||
// var allplayers = '';
|
||
// for (const property of bot.tabcompleteplayers) {
|
||
// if (property.match.startsWith('@')) continue;
|
||
// // eslint-disable-next-line no-redeclare
|
||
// var allplayers = allplayers + '\n`' + property.match + '` > `' + bot.players.getPlayer(property.match).UUID + '`';
|
||
// }
|
||
// const Embed = new MessageEmbed()
|
||
// .setColor('#FFFF00')
|
||
// .setTitle('Players')
|
||
// .setDescription(allplayers);
|
||
// channeldc.send({embeds: [Embed]});
|
||
// return;
|
||
// }
|
||
//
|
||
// if (message.content.toLowerCase().startsWith('!')) {
|
||
// const args = message.content.toLowerCase().substring(1).trim().split(' ');
|
||
// const Embed = new MessageEmbed()
|
||
// .setColor('#FF0000')
|
||
// .setTitle('Error')
|
||
// .setDescription(`Unknown command or incomplete command: "${args.at(0)}"`);
|
||
// channeldc.send({embeds: [Embed]});
|
||
// return;
|
||
// }
|
||
// } catch (e) {
|
||
// console.log(e);
|
||
// }
|
||
try {
|
||
const attachment = message.attachments.at(0);
|
||
if (attachment!=undefined) {
|
||
if (message.content.toLowerCase()==='') {
|
||
bot.core.run(`minecraft:tellraw @a ["",{"text":"[","color":"dark_gray"},{"text":"ChomeNS ","color":"yellow","clickEvent":{"action":"open_url","value":"https://discord.gg/xdgCkUyaA4"},"hoverEvent":{"action":"show_text","contents":[{"text":"https://discord.gg/xdgCkUyaA4 ","color":"blue"},{"text":"<-- join now","color":"red"}]}},{"text":"Discord","color":"blue","clickEvent":{"action":"open_url","value":"https://discord.gg/xdgCkUyaA4"},"hoverEvent":{"action":"show_text","contents":[{"text":"https://discord.gg/xdgCkUyaA4 ","color":"blue"},{"text":"<-- join now","color":"red"}]}},{"text":"] ","color":"dark_gray"},{"text":"${message.member.displayName}","color":"red","clickEvent":{"action":"copy_to_clipboard","value":"${message.author.username}#${message.author.discriminator}"},"hoverEvent":{"action":"show_text","value":{"text":"${message.author.username}§7#${message.author.discriminator}"} }},{"text":" › ","color":"dark_gray"},` + `{"text":"[Attachment]","clickEvent":{"action":"open_url","value":"${attachment.proxyURL}"},"color":"green"}` + ']');
|
||
} else {
|
||
bot.core.run(`minecraft:tellraw @a ["",{"text":"[","color":"dark_gray"},{"text":"ChomeNS ","color":"yellow","clickEvent":{"action":"open_url","value":"https://discord.gg/xdgCkUyaA4"},"hoverEvent":{"action":"show_text","contents":[{"text":"https://discord.gg/xdgCkUyaA4 ","color":"blue"},{"text":"<-- join now","color":"red"}]}},{"text":"Discord","color":"blue","clickEvent":{"action":"open_url","value":"https://discord.gg/xdgCkUyaA4"},"hoverEvent":{"action":"show_text","contents":[{"text":"https://discord.gg/xdgCkUyaA4 ","color":"blue"},{"text":"<-- join now","color":"red"}]}},{"text":"] ","color":"dark_gray"},{"text":"${message.member.displayName}","color":"red","clickEvent":{"action":"copy_to_clipboard","value":"${message.author.username}#${message.author.discriminator}"},"hoverEvent":{"action":"show_text","value":{"text":"${message.author.username}§7#${message.author.discriminator}"} }},{"text":" › ","color":"dark_gray"},` + MessageBuilder.fromString('&7' + message.content) + `,{"text":" [Attachment]","clickEvent":{"action":"open_url","value":"${attachment.proxyURL}"},"color":"green"}` + ']');
|
||
}
|
||
} else {
|
||
bot.core.run(`minecraft:tellraw @a ["",{"text":"[","color":"dark_gray"},{"text":"ChomeNS ","color":"yellow","clickEvent":{"action":"open_url","value":"https://discord.gg/xdgCkUyaA4"},"hoverEvent":{"action":"show_text","contents":[{"text":"https://discord.gg/xdgCkUyaA4 ","color":"blue"},{"text":"<-- join now","color":"red"}]}},{"text":"Discord","color":"blue","clickEvent":{"action":"open_url","value":"https://discord.gg/xdgCkUyaA4"},"hoverEvent":{"action":"show_text","contents":[{"text":"https://discord.gg/xdgCkUyaA4 ","color":"blue"},{"text":"<-- join now","color":"red"}]}},{"text":"] ","color":"dark_gray"},{"text":"${message.member.displayName}","color":"red","clickEvent":{"action":"copy_to_clipboard","value":"${message.author.username}#${message.author.discriminator}"},"hoverEvent":{"action":"show_text","value":{"text":"${message.author.username}§7#${message.author.discriminator}"} }},{"text":" › ","color":"dark_gray"},` + MessageBuilder.fromString('&7' + message.content) + ']');
|
||
}
|
||
} catch (e) {
|
||
return;
|
||
}
|
||
});
|
||
|
||
dcclient.login(config.discord.token);
|