mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-23 15:47:57 -05:00
f078a5e056
i found out about this when i did .wiki and nothing happens
34 lines
1.3 KiB
JavaScript
34 lines
1.3 KiB
JavaScript
/* eslint-disable max-len */
|
|
const {MessageEmbed} = require('discord.js');
|
|
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, config, hash, ownerhash, selector) {
|
|
try {
|
|
const res = await translate(args.slice(2).join(' '), {from: args[0], to: args[1]});
|
|
bot.tellraw(selector, [{text: 'Result: ', color: 'gold'}, {text: res.text, color: 'green'}]);
|
|
} catch (e) {
|
|
bot.tellraw(selector, {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]});
|
|
}
|
|
},
|
|
};
|