Skip to content

Instantly share code, notes, and snippets.

@seishun
Created June 4, 2017 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seishun/5feac8c4886b8f81140656fb9e5591ac to your computer and use it in GitHub Desktop.
Save seishun/5feac8c4886b8f81140656fb9e5591ac to your computer and use it in GitHub Desktop.
stupid translator bot
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