Drop Translate

This commit is contained in:
Daniel Odendahl Jr
2017-04-16 01:48:38 +00:00
parent fb9f723f1c
commit bb5b93f8e4
8 changed files with 4 additions and 171 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ You can join the home server with [this link](https://discord.gg/fqQF8mc).
[discord.js](https://discord.js.org/#/), [commando](https://github.com/Gawdl3y/discord.js-commando), [zalgoize](https://github.com/clux/zalgolize), [snekfetch](https://github.com/GusCaplan/snekfetch), [mathjs](http://mathjs.org/), [moment](http://momentjs.com), [moment-duration-format](https://github.com/jsmreese/moment-duration-format), [jimp](https://github.com/oliver-moran/jimp), [cheerio](https://cheerio.js.org/)
## APIs
[Wattpad](https://developer.wattpad.com/docs/api), [Wordnik](http://developer.wordnik.com/docs.html), [osu!](https://osu.ppy.sh/p/api), [memegen.link](https://memegen.link/), [Yugioh Prices](http://docs.yugiohprices.apiary.io/#), [YouTube Data](https://developers.google.com/youtube/v3/), [Yoda Speak](https://market.mashape.com/ismaelc/yoda-speak), [Discord Bots](https://bots.discord.pw/api), [Today in History](http://history.muffinlabs.com/#api), [jService](http://jservice.io/), [Strawpoll](https://github.com/strawpoll/strawpoll/wiki/API), [Urban Dictionary](https://github.com/zdict/zdict/wiki/Urban-dictionary-API-documentation), [OMDB](http://www.omdbapi.com/), [Yahoo Weather](https://developer.yahoo.com/weather/), [Yandex.Translate](https://translate.yandex.com/developers), [Wikipedia](https://en.wikipedia.org/w/api.php), [Google Static Maps](https://developers.google.com/maps/documentation/static-maps/)
[Wattpad](https://developer.wattpad.com/docs/api), [Wordnik](http://developer.wordnik.com/docs.html), [osu!](https://osu.ppy.sh/p/api), [memegen.link](https://memegen.link/), [Yugioh Prices](http://docs.yugiohprices.apiary.io/#), [YouTube Data](https://developers.google.com/youtube/v3/), [Yoda Speak](https://market.mashape.com/ismaelc/yoda-speak), [Discord Bots](https://bots.discord.pw/api), [Today in History](http://history.muffinlabs.com/#api), [jService](http://jservice.io/), [Strawpoll](https://github.com/strawpoll/strawpoll/wiki/API), [Urban Dictionary](https://github.com/zdict/zdict/wiki/Urban-dictionary-API-documentation), [OMDB](http://www.omdbapi.com/), [Yahoo Weather](https://developer.yahoo.com/weather/), [Google Static Maps](https://developers.google.com/maps/documentation/static-maps/)
## Self-Hosting
You can Self-Host the bot easily, provided you have API keys and a Discord Bot Token. [Node.js](https://nodejs.org/en/) is also required, with at least version 7.8.0 recommended.
-97
View File
@@ -1,97 +0,0 @@
{
"languages": {
"af": "Afrikaans",
"am": "Amharic",
"ar": "Arabic",
"az": "Azerbaijani",
"ba": "Bashkir",
"be": "Belarusian",
"bg": "Bulgarian",
"bn": "Bengali",
"bs": "Bosnian",
"ca": "Catalan",
"ceb": "Cebuano",
"cs": "Czech",
"cy": "Welsh",
"da": "Danish",
"de": "German",
"el": "Greek",
"en": "English",
"eo": "Esperanto",
"es": "Spanish",
"et": "Estonian",
"eu": "Basque",
"fa": "Persian",
"fi": "Finnish",
"fr": "French",
"ga": "Irish",
"gd": "Scots Gaelic",
"gl": "Galician",
"gu": "Gujarati",
"he": "Hebrew",
"hi": "Hindi",
"hr": "Croatian",
"ht": "Haitian",
"hu": "Hungarian",
"hy": "Armenian",
"id": "Indonesian",
"is": "Icelandic",
"it": "Italian",
"ja": "Japanese",
"jv": "Javanese",
"ka": "Georgian",
"kk": "Kazakh",
"km": "Khmer",
"kn": "Kannada",
"ko": "Korean",
"ky": "Kyrgyz",
"la": "Latin",
"lb": "Luxembourgish",
"lo": "Loa",
"lt": "Lithuanian",
"lv": "Latvian",
"mg": "Malagasy",
"mhr": "Mari",
"mi": "Maori",
"mk": "Macedonian",
"ml": "Malayalam",
"mn": "Mongolian",
"mr": "Marathi",
"mrj": "Hill Mari",
"ms": "Malay",
"mt": "Maltese",
"my": "Burmese",
"ne": "Nepali",
"nl": "Dutch",
"no": "Norwegian",
"pa": "Punjabi",
"pap": "Papiamento",
"pl": "Polish",
"pt": "Portuguese",
"ro": "Romanian",
"ru": "Russian",
"si": "Sinhalese",
"sk": "Slovak",
"sl": "Slovenian",
"sq": "Albanian",
"sr": "Serbian",
"su": "Sundanese",
"sv": "Swedish",
"sw": "Swahili",
"ta": "Tamil",
"te": "Telugu",
"tg": "Tajik",
"th": "Thai",
"tl": "Tagalog",
"tr": "Turkish",
"tt": "Tatar",
"udm": "Udmurt",
"uk": "Ukrainian",
"ur": "Urdu",
"uz": "Uzbek",
"vi": "Vietnamese",
"xh": "Xhosa",
"yi": "Yiddish",
"zh": "Chinese"
}
}
-66
View File
@@ -1,66 +0,0 @@
const { Command } = require('discord.js-commando');
const { RichEmbed } = require('discord.js');
const snekfetch = require('snekfetch');
const { languages } = require('./languages.json');
module.exports = class TranslateCommand extends Command {
constructor(client) {
super(client, {
name: 'translate',
group: 'textedit',
memberName: 'translate',
description: 'Translates text to a given language. (;translate ja Give me the money!)',
details: '**Codes:** af: Afrikaans, am: Amharic, ar: Arabic, az: Azerbaijani, ba: Bashkir, be: Belarusian, bg: Bulgarian, bn: Bengali, bs: Bosnian, ca: Catalan, ceb: Cebuano, cs: Czech, cy: Welsh, da: Danish, de: German, el: Greek, en: English, eo: Esperanto, es: Spanish, et: Estonian, eu: Basque, fa: Persian, fi: Finnish, fr: French, ga: Irish, gd: Scots Gaelic, gl: Galician, gu: Gujarati, he: Hebrew, hi: Hindi, hr: Croatian, ht: Haitian, hu: Hungarian, hy: Armenian, id: Indonesian, is: Icelandic, it: Italian, ja: Japanese, jv: Javanese, ka: Georgian, kk: Kazakh, km: Khmer, kn: Kannada, ko: Korean, ky: Kyrgyz, la: Latin, lb: Luxembourgish, lo: Loa, lt: Lithuanian, lv: Latvian, mg: Malagasy, mhr: Mari, mi: Maori, mk: Macedonian, ml: Malayalam, mn: Mongolian, mr: Marathi, mrj: Hill Mari, ms: Malay, mt: Maltese, my: Burmese, ne: Nepali, nl: Dutch, no: Norwegian, pa: Punjabi, pap: Papiamento, pl: Polish, pt: Portuguese, ro: Romanian, ru: Russian, si: Sinhalese, sk: Slovak, sl: Slovenian, sq: Albanian, sr: Serbian, su: Sundanese, sv: Swedish, sw: Swahili, ta: Tamil, te: Telugu, tg: Tajik, th: Thai, tl: Tagalog, tr: Turkish, tt: Tatar, udm: Udmurt, uk: Ukrainian, ur: Urdu, uz: Uzbek, vi: Vietnamese, xh: Xhosa, yi: Yiddish, zh: Chinese',
examples: [';translate ja Give me the the money!'],
args: [{
key: 'to',
prompt: 'What language would you like to translate to?',
type: 'string',
validate: to => {
if (languages[to.toLowerCase()]) {
return true;
}
return 'Please enter a valid language code. Use `;help translate` for a list of codes.';
}
}, {
key: 'text',
prompt: 'What text would you like to translate?',
type: 'string',
validate: content => {
if (content.length > 200) {
return 'Please keep translation queries under 200 characters.';
}
return true;
}
}]
});
}
async run(message, args) {
if (message.channel.type !== 'dm') {
if (!message.channel.permissionsFor(this.client.user).hasPermission(['SEND_MESSAGES', 'READ_MESSAGES'])) return;
if (!message.channel.permissionsFor(this.client.user).hasPermission('EMBED_LINKS')) return message.say(':x: Error! I don\'t have the Embed Links Permission!');
}
const language = args.to.toLowerCase();
const query = encodeURIComponent(args.text);
try {
const response = await snekfetch
.get(`https://translate.yandex.net/api/v1.5/tr.json/translate?key=${process.env.YANDEX_KEY}&lang=${language}&text=${query}`);
const data = response.body;
const translated = data.text[0];
const langs = data.lang.split('-');
const langTo = langs[1];
const langFrom = langs[0];
const embed = new RichEmbed()
.setColor(0x00AE86)
.addField(`Input (From: ${languages[langFrom]}):`,
query)
.addField(`Translation (To: ${languages[langTo]}):`,
translated);
return message.embed(embed);
}
catch (err) {
return message.say(':x: Error! Something went wrong!');
}
}
};
+2 -2
View File
@@ -33,7 +33,7 @@ module.exports = class InfoCommand extends Command {
.addField('Shards',
`${this.client.options.shardCount} (${this.client.shard.id})`, true)
.addField('Commands',
'111', true)
'110', true)
.addField('Owner',
'dragonfire535#8081', true)
.addField('Source Code',
@@ -49,7 +49,7 @@ module.exports = class InfoCommand extends Command {
.addField('Modules',
'[commando](https://github.com/Gawdl3y/discord.js-commando), [zalgoize](https://github.com/clux/zalgolize), [snekfetch](https://github.com/GusCaplan/snekfetch), [mathjs](http://mathjs.org/), [moment](http://momentjs.com), [moment-duration-format](https://github.com/jsmreese/moment-duration-format), [jimp](https://github.com/oliver-moran/jimp), [cheerio](https://cheerio.js.org/)')
.addField('APIs',
'[Wattpad](https://developer.wattpad.com/docs/api), [Wordnik](http://developer.wordnik.com/docs.html), [osu!](https://osu.ppy.sh/p/api), [memegen.link](https://memegen.link/), [Yugioh Prices](http://docs.yugiohprices.apiary.io/#), [YouTube Data](https://developers.google.com/youtube/v3/), [Yoda Speak](https://market.mashape.com/ismaelc/yoda-speak), [Discord Bots](https://bots.discord.pw/api), [Today in History](http://history.muffinlabs.com/#api), [jService](http://jservice.io/), [Strawpoll](https://github.com/strawpoll/strawpoll/wiki/API), [Urban Dictionary](https://github.com/zdict/zdict/wiki/Urban-dictionary-API-documentation), [OMDB](http://www.omdbapi.com/), [Yahoo Weather](https://developer.yahoo.com/weather/), [Yandex.Translate](https://translate.yandex.com/developers), [Wikipedia](https://en.wikipedia.org/w/api.php), [Google Static Maps](https://developers.google.com/maps/documentation/static-maps/)');
'[Wattpad](https://developer.wattpad.com/docs/api), [Wordnik](http://developer.wordnik.com/docs.html), [osu!](https://osu.ppy.sh/p/api), [memegen.link](https://memegen.link/), [Yugioh Prices](http://docs.yugiohprices.apiary.io/#), [YouTube Data](https://developers.google.com/youtube/v3/), [Yoda Speak](https://market.mashape.com/ismaelc/yoda-speak), [Discord Bots](https://bots.discord.pw/api), [Today in History](http://history.muffinlabs.com/#api), [jService](http://jservice.io/), [Strawpoll](https://github.com/strawpoll/strawpoll/wiki/API), [Urban Dictionary](https://github.com/zdict/zdict/wiki/Urban-dictionary-API-documentation), [OMDB](http://www.omdbapi.com/), [Yahoo Weather](https://developer.yahoo.com/weather/), [Wikipedia](https://en.wikipedia.org/w/api.php), [Google Static Maps](https://developers.google.com/maps/documentation/static-maps/)');
return message.embed(embed);
}
};
-1
View File
@@ -42,7 +42,6 @@
<li><a href="https://github.com/zdict/zdict/wiki/Urban-dictionary-API-documentation">Urban Dictionary</a></li>
<li><a href="http://www.omdbapi.com/">OMDB</a></li>
<li><a href="https://developer.yahoo.com/weather/">Yahoo Weather</a></li>
<li><a href="https://translate.yandex.com/developers">Yandex.Translate</a></li>
<li><a href="https://en.wikipedia.org/w/api.php">Wikipedia</a></li>
<li><a href="https://developers.google.com/maps/documentation/static-maps/">Google Static Maps</a></li>
</ul>
-1
View File
@@ -42,7 +42,6 @@
<li>Get Yu-Gi-Oh! Card Data</li>
<li>Pirate, Binary, and Yoda Translators</li>
<li>Reverse Text</li>
<li>Translate Text</li>
<li>Zalgoize Text</li>
<li>And so so so much more!</li>
</ul>
-2
View File
@@ -47,7 +47,6 @@
<li>Get Yu-Gi-Oh! Card Data</li>
<li>Pirate, Binary, and Yoda Translators</li>
<li>Reverse Text</li>
<li>Translate Text</li>
<li>Zalgoize Text</li>
<li>And so so so much more!</li>
</ul>
@@ -88,7 +87,6 @@
<li><a href="https://github.com/zdict/zdict/wiki/Urban-dictionary-API-documentation">Urban Dictionary</a></li>
<li><a href="http://www.omdbapi.com/">OMDB</a></li>
<li><a href="https://developer.yahoo.com/weather/">Yahoo Weather</a></li>
<li><a href="https://translate.yandex.com/developers">Yandex.Translate</a></li>
<li><a href="https://en.wikipedia.org/w/api.php">Wikipedia</a></li>
<li><a href="https://developers.google.com/maps/documentation/static-maps/">Google Static Maps</a></li>
</ul>
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiaobot",
"version": "25.0.0",
"version": "25.1.0",
"description": "A Discord Bot",
"main": "shardingmanager.js",
"scripts": {