Created
June 4, 2017 21:18
-
-
Save seishun/5feac8c4886b8f81140656fb9e5591ac to your computer and use it in GitHub Desktop.
stupid translator bot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Discord = require("discord.js"); | |
const translate = require('google-translate-api'); | |
const client = new Discord.Client(); | |
client.on('ready', () => { | |
console.log(`Logged in as ${client.user.username}!`); | |
}); | |
client.on('message', msg => { | |
if (msg.author.username == 'Kokoa') | |
return; | |
if (msg.content.startsWith('.')) | |
return; | |
translate(msg.content, {to: 'en'}).then(res => { | |
if (['ru', 'ja', 'it'].includes(res.from.language.iso)) { | |
msg.channel.send({ | |
embed: { | |
color: 0x4a8af4, | |
description: res.text, | |
title: `${msg.author.username} said:`, | |
footer: { | |
text: `Translated from ${res.from.language.iso}` | |
} | |
} | |
}); | |
} | |
}); | |
}); | |
client.login('nope'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment