mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-12-18 03:12:23 -05:00
18 lines
742 B
JavaScript
18 lines
742 B
JavaScript
|
/* eslint-disable max-len */
|
||
|
const translate = require('@vitalets/google-translate-api');
|
||
|
module.exports = {
|
||
|
name: 'translate',
|
||
|
alias: [],
|
||
|
description: 'Translate a message from any language to any language using Google Translate',
|
||
|
usage: '<language 1> <language 2> <message>',
|
||
|
trusted: 0,
|
||
|
execute: async function(bot, username, usernameraw, sender, prefix, args) {
|
||
|
try {
|
||
|
const res = await translate(args.slice(2).join(' '), {from: args[0], to: args[1]});
|
||
|
bot.core.run('minecraft:tellraw @a ' + JSON.stringify(['', {text: 'Result: ', color: 'gold'}, {text: res.text, color: 'green'}]));
|
||
|
} catch (e) {
|
||
|
bot.core.run('minecraft:tellraw @a ' + JSON.stringify({text: String(e), color: 'red'}));
|
||
|
}
|
||
|
},
|
||
|
};
|