added some nice embed
This commit is contained in:
parent
580eed9cdc
commit
cb38ef3eb8
1 changed files with 15 additions and 3 deletions
|
@ -2,7 +2,8 @@ const { Command } = require('discord.js-commando');
|
|||
const fetch = require('node-fetch')
|
||||
const SelfReloadJSON = require('self-reload-json');
|
||||
const blacklist = require('../../blacklist');
|
||||
const { yandexAPI } = require('../../config.json')
|
||||
const Discord = require('discord.js');
|
||||
const { yandexAPI } = require('../../config.json');
|
||||
|
||||
module.exports = class translationCommand extends Command {
|
||||
constructor(client) {
|
||||
|
@ -27,13 +28,24 @@ module.exports = class translationCommand extends Command {
|
|||
if(blacklistJson[message.author.id])
|
||||
return blacklist(blacklistJson[message.author.id] , message)
|
||||
|
||||
fetch(`https://translate.yandex.net/api/v1.5/tr.json/translate?key=${yandexAPI}&text=${text}&lang=en`,{
|
||||
fetch(`https://translate.yandex.net/api/v1.5/tr.json/translate?key=${yandexAPI}&text=${text}&lang=en&options=1`,{
|
||||
}).then((response) => {
|
||||
return response.json();
|
||||
}).then((response) => {
|
||||
if (response.code != '200')
|
||||
return message.say('An error has occured')
|
||||
|
||||
message.say(`${response.text[0]}`)
|
||||
|
||||
const translationEmbed = new Discord.RichEmbed()
|
||||
.setColor('#0099ff')
|
||||
.setTitle('Asked for the following translation:')
|
||||
.setAuthor(message.author.username)
|
||||
.setDescription(response.text[0])
|
||||
.addField('Original text', text)
|
||||
.addField('Translated from', response.detected.lang)
|
||||
.setTimestamp()
|
||||
.setFooter('Powered by Yandex.Translate ');
|
||||
|
||||
message.say(translationEmbed)
|
||||
});
|
||||
}};
|
Loading…
Reference in a new issue