mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-14 10:44:55 -05:00
fix help + add uptime, translate discord support
This commit is contained in:
parent
479e132e15
commit
21a93ef844
3 changed files with 39 additions and 11 deletions
|
@ -42,9 +42,9 @@ module.exports = {
|
|||
bot.core.run('minecraft:tellraw @a ' + JSON.stringify([{text: prefix + command.name, color: 'gold'}, {text: ' ' + command.usage, color: 'aqua'}]));
|
||||
}
|
||||
|
||||
if (command.name===args[0]) m();
|
||||
if (command.name === args[0]) m();
|
||||
for (const alias of command.alias) {
|
||||
if (alias===args[0]) m();
|
||||
if (alias === args[0]) m();
|
||||
}
|
||||
};
|
||||
} else {
|
||||
|
@ -52,12 +52,10 @@ module.exports = {
|
|||
bot.core.run('minecraft:tellraw @a ' + JSON.stringify([pre, {text: generalCommands, color: 'green'}, {text: trustedCommands, color: 'red'}, {text: ownerCommands, color: 'dark_red'}]));
|
||||
}
|
||||
},
|
||||
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc) {
|
||||
discordExecute: async function(bot, username, usernameraw, sender, prefix, args, channeldc) {
|
||||
if (typeof args[0]!=='undefined') {
|
||||
let sent = false;
|
||||
|
||||
for (const command of bot.command_handler.commands) {
|
||||
if (command.name===args[0]) {
|
||||
function m() {
|
||||
let discordSupported;
|
||||
let alias = command.name;
|
||||
if (typeof command.discordExecute==='undefined') {
|
||||
|
@ -71,12 +69,17 @@ module.exports = {
|
|||
const Embed = new MessageEmbed()
|
||||
.setColor('#FFFF00')
|
||||
.setTitle(`${prefix + command.name} (${alias}) - ${command.description}`)
|
||||
.setDescription(`Trust level: ${command.trusted}` + '\n' + `${prefix + command.name} ${command.usage}` + '\n' + `Supported: ${discordSupported}`);
|
||||
.setDescription(`Trust level: ${command.trusted}` + '\n' +
|
||||
`Supported: ${discordSupported}` + '\n' +
|
||||
`${prefix + command.name} ${command.usage}`,
|
||||
);
|
||||
channeldc.send({embeds: [Embed]});
|
||||
|
||||
sent = true;
|
||||
}
|
||||
if (!sent) throw new SyntaxError('Invalid command');
|
||||
|
||||
if (command.name === args[0]) m();
|
||||
for (const alias of command.alias) {
|
||||
if (alias === args[0]) m();
|
||||
}
|
||||
};
|
||||
} else {
|
||||
let supportedCommands = '';
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint-disable max-len */
|
||||
const {MessageEmbed} = require('discord.js');
|
||||
const translate = require('@vitalets/google-translate-api');
|
||||
module.exports = {
|
||||
name: 'translate',
|
||||
|
@ -14,4 +15,20 @@ module.exports = {
|
|||
bot.core.run('minecraft:tellraw @a ' + JSON.stringify({text: String(e), color: 'red'}));
|
||||
}
|
||||
},
|
||||
discordExecute: async function(bot, username, usernameraw, sender, prefix, args, channeldc, message) {
|
||||
try {
|
||||
const res = await translate(args.slice(2).join(' '), {from: args[0], to: args[1]});
|
||||
const Embed = new MessageEmbed()
|
||||
.setColor('#FFFF00')
|
||||
.setTitle('Result')
|
||||
.setDescription(res.text);
|
||||
channeldc.send({embeds: [Embed]});
|
||||
} catch (e) {
|
||||
const Embed = new MessageEmbed()
|
||||
.setColor('#FF0000')
|
||||
.setTitle('Error')
|
||||
.setDescription(`\`\`\`${e}\`\`\``);
|
||||
channeldc.send({embeds: [Embed]});
|
||||
}
|
||||
},
|
||||
};
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/* eslint-disable max-len */
|
||||
const {MessageEmbed} = require('discord.js');
|
||||
const {secondsToHms} = require('../util/secondToHms');
|
||||
module.exports = {
|
||||
name: 'uptime',
|
||||
|
@ -7,6 +8,13 @@ module.exports = {
|
|||
usage: '',
|
||||
trusted: 0,
|
||||
execute: function(bot) {
|
||||
bot.core.run(`minecraft:tellraw @a ["",{"text":"The bot's uptime is ","color":"white"},{"text":"${secondsToHms(Math.floor(performance.now() / 1000))}","color":"green"}]`); return;
|
||||
bot.core.run('minecraft:tellraw @a ' + JSON.stringify(['', {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) {
|
||||
const Embed = new MessageEmbed()
|
||||
.setColor('#FFFF00')
|
||||
.setTitle('Bot\'s Uptime')
|
||||
.setDescription(`The bot\'s uptime is ${secondsToHms(Math.floor(performance.now() / 1000))}`);
|
||||
channeldc.send({embeds: [Embed]});
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue