2022-12-24 00:59:52 -05:00
|
|
|
const { EmbedBuilder } = require('discord.js')
|
2022-12-25 05:45:06 -05:00
|
|
|
const { translate } = require('@vitalets/google-translate-api')
|
2022-08-14 05:51:45 -04:00
|
|
|
module.exports = {
|
|
|
|
name: 'translate',
|
|
|
|
alias: [],
|
2022-12-25 07:09:39 -05:00
|
|
|
description: 'Translate a message using Google Translate',
|
2022-08-14 05:51:45 -04:00
|
|
|
usage: '<language 1> <language 2> <message>',
|
|
|
|
trusted: 0,
|
2022-12-14 08:51:30 -05:00
|
|
|
execute: async function (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
2022-08-14 05:51:45 -04:00
|
|
|
try {
|
2022-11-27 02:35:28 -05:00
|
|
|
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' }])
|
2022-08-14 05:51:45 -04:00
|
|
|
} catch (e) {
|
2022-11-27 02:35:28 -05:00
|
|
|
bot.tellraw(selector, { text: String(e), color: 'red' })
|
2022-08-14 05:51:45 -04:00
|
|
|
}
|
|
|
|
},
|
2022-12-14 08:51:30 -05:00
|
|
|
discordExecute: async function (bot, username, sender, prefix, args, channeldc, message, config) {
|
2022-10-15 00:45:40 -04:00
|
|
|
try {
|
2022-11-27 02:35:28 -05:00
|
|
|
const res = await translate(args.slice(2).join(' '), { from: args[0], to: args[1] })
|
2022-12-24 00:59:52 -05:00
|
|
|
const Embed = new EmbedBuilder()
|
2022-12-01 05:15:30 -05:00
|
|
|
.setColor(config.discord.embedsColors.normal)
|
2022-11-27 02:35:28 -05:00
|
|
|
.setTitle('Result')
|
|
|
|
.setDescription(res.text)
|
|
|
|
channeldc.send({ embeds: [Embed] })
|
2022-10-15 00:45:40 -04:00
|
|
|
} catch (e) {
|
2022-12-24 00:59:52 -05:00
|
|
|
const Embed = new EmbedBuilder()
|
2022-12-01 05:15:30 -05:00
|
|
|
.setColor(config.discord.embedsColors.error)
|
2022-11-27 02:35:28 -05:00
|
|
|
.setTitle('Error')
|
|
|
|
.setDescription(`\`\`\`${e}\`\`\``)
|
|
|
|
channeldc.send({ embeds: [Embed] })
|
2022-10-15 00:45:40 -04:00
|
|
|
}
|
2022-11-27 02:35:28 -05:00
|
|
|
}
|
|
|
|
}
|