mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-06 14:20:51 +02:00
Translate Manual Request
This commit is contained in:
@@ -13,7 +13,7 @@ You can add XiaoBot to your server with [this link](https://discordapp.com/oauth
|
||||
You can join the home server with [this link](https://discord.gg/fqQF8mc).
|
||||
|
||||
## Modules & APIs
|
||||
[discord.js](https://discord.js.org/#/), [commando](https://github.com/Gawdl3y/discord.js-commando), [pirate-speak](https://github.com/mikewesthad/pirate-speak), [google-translate-api](https://github.com/matheuss/google-translate-api), [zalgoize](https://github.com/clux/zalgolize), [hepburn](https://github.com/lovell/hepburn), [string-to-binary](https://www.npmjs.com/package/string-to-binary), [roman-numeral-converter-mmxvi](https://github.com/Cein-Markey/roman-numeral-conversion-library), [cowsay](https://github.com/piuccio/cowsay), [morse](https://github.com/ecto/morse), [superagent](https://github.com/visionmedia/superagent), [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/), [Wattpad API](https://developer.wattpad.com/docs/api), [Wordnik API](http://developer.wordnik.com/docs.html), [osu! API](https://osu.ppy.sh/p/api), [memegen.link](https://memegen.link/), [Yugioh Prices API](http://docs.yugiohprices.apiary.io/#), [YouTube Data API](https://developers.google.com/youtube/v3/), [Yoda Speak API](https://market.mashape.com/ismaelc/yoda-speak), [Discord Bots API](https://bots.discord.pw/api), [Today in History API](http://history.muffinlabs.com/#api), [jService API](http://jservice.io/), [Strawpoll API](https://github.com/strawpoll/strawpoll/wiki/API), [Urban Dictionary API](https://github.com/zdict/zdict/wiki/Urban-dictionary-API-documentation), [OMDB API](http://www.omdbapi.com/), [Yahoo Weather API](https://developer.yahoo.com/weather/)
|
||||
[discord.js](https://discord.js.org/#/), [commando](https://github.com/Gawdl3y/discord.js-commando), [pirate-speak](https://github.com/mikewesthad/pirate-speak), [zalgoize](https://github.com/clux/zalgolize), [hepburn](https://github.com/lovell/hepburn), [string-to-binary](https://www.npmjs.com/package/string-to-binary), [roman-numeral-converter-mmxvi](https://github.com/Cein-Markey/roman-numeral-conversion-library), [cowsay](https://github.com/piuccio/cowsay), [morse](https://github.com/ecto/morse), [superagent](https://github.com/visionmedia/superagent), [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/), [Wattpad API](https://developer.wattpad.com/docs/api), [Wordnik API](http://developer.wordnik.com/docs.html), [osu! API](https://osu.ppy.sh/p/api), [memegen.link](https://memegen.link/), [Yugioh Prices API](http://docs.yugiohprices.apiary.io/#), [YouTube Data API](https://developers.google.com/youtube/v3/), [Yoda Speak API](https://market.mashape.com/ismaelc/yoda-speak), [Discord Bots API](https://bots.discord.pw/api), [Today in History API](http://history.muffinlabs.com/#api), [jService API](http://jservice.io/), [Strawpoll API](https://github.com/strawpoll/strawpoll/wiki/API), [Urban Dictionary API](https://github.com/zdict/zdict/wiki/Urban-dictionary-API-documentation), [OMDB API](http://www.omdbapi.com/), [Yahoo Weather API](https://developer.yahoo.com/weather/)
|
||||
|
||||
## 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.
|
||||
|
||||
@@ -47,7 +47,7 @@ module.exports = class InfoCommand extends commando.Command {
|
||||
.addField('Library',
|
||||
'[discord.js](https://discord.js.org/#/)', true)
|
||||
.addField('Modules',
|
||||
'[commando](https://github.com/Gawdl3y/discord.js-commando), [pirate-speak](https://github.com/mikewesthad/pirate-speak), [google-translate-api](https://github.com/matheuss/google-translate-api), [zalgoize](https://github.com/clux/zalgolize), [hepburn](https://github.com/lovell/hepburn), [string-to-binary](https://www.npmjs.com/package/string-to-binary), [roman-numeral-converter-mmxvi](https://github.com/Cein-Markey/roman-numeral-conversion-library), [cowsay](https://github.com/piuccio/cowsay), [morse](https://github.com/ecto/morse), [superagent](https://github.com/visionmedia/superagent), [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/)')
|
||||
'[commando](https://github.com/Gawdl3y/discord.js-commando), [pirate-speak](https://github.com/mikewesthad/pirate-speak), [zalgoize](https://github.com/clux/zalgolize), [hepburn](https://github.com/lovell/hepburn), [string-to-binary](https://www.npmjs.com/package/string-to-binary), [roman-numeral-converter-mmxvi](https://github.com/Cein-Markey/roman-numeral-conversion-library), [cowsay](https://github.com/piuccio/cowsay), [morse](https://github.com/ecto/morse), [superagent](https://github.com/visionmedia/superagent), [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 API](https://developer.wattpad.com/docs/api), [Wordnik API](http://developer.wordnik.com/docs.html), [osu! API](https://osu.ppy.sh/p/api), [memegen.link](https://memegen.link/), [Yugioh Prices API](http://docs.yugiohprices.apiary.io/#), [YouTube Data API](https://developers.google.com/youtube/v3/), [Yoda Speak API](https://market.mashape.com/ismaelc/yoda-speak), [Discord Bots API](https://bots.discord.pw/api), [Today in History API](http://history.muffinlabs.com/#api), [jService API](http://jservice.io/), [Strawpoll API](https://github.com/strawpoll/strawpoll/wiki/API), [Urban Dictionary API](https://github.com/zdict/zdict/wiki/Urban-dictionary-API-documentation), [OMDB API](http://www.omdbapi.com/), [Yahoo Weather API](https://developer.yahoo.com/weather/)');
|
||||
return message.embed(embed);
|
||||
|
||||
@@ -1,24 +1,19 @@
|
||||
const commando = require('discord.js-commando');
|
||||
const Discord = require('discord.js');
|
||||
const translate = require('google-translate-api');
|
||||
const request = require('superagent');
|
||||
const languages = {
|
||||
"auto": "Automatic",
|
||||
"af": "Afrikaans",
|
||||
"sq": "Albanian",
|
||||
"ar": "Arabic",
|
||||
"hy": "Armenian",
|
||||
"az": "Azerbaijani",
|
||||
"eu": "Basque",
|
||||
"be": "Belarusian",
|
||||
"bn": "Bengali",
|
||||
"bs": "Bosnian",
|
||||
"be": "Belarusian",
|
||||
"bg": "Bulgarian",
|
||||
"ca": "Catalan",
|
||||
"ceb": "Cebuano",
|
||||
"ny": "Chichewa",
|
||||
"zh-cn": "Chinese Simplified",
|
||||
"zh-tw": "Chinese Traditional",
|
||||
"co": "Corsican",
|
||||
"hr": "Croatian",
|
||||
"cs": "Czech",
|
||||
"da": "Danish",
|
||||
@@ -29,83 +24,50 @@ const languages = {
|
||||
"tl": "Filipino",
|
||||
"fi": "Finnish",
|
||||
"fr": "French",
|
||||
"fy": "Frisian",
|
||||
"gl": "Galician",
|
||||
"ka": "Georgian",
|
||||
"de": "German",
|
||||
"el": "Greek",
|
||||
"gu": "Gujarati",
|
||||
"ht": "Haitian Creole",
|
||||
"ha": "Hausa",
|
||||
"haw": "Hawaiian",
|
||||
"iw": "Hebrew",
|
||||
"hi": "Hindi",
|
||||
"hmn": "Hmong",
|
||||
"hu": "Hungarian",
|
||||
"is": "Icelandic",
|
||||
"ig": "Igbo",
|
||||
"id": "Indonesian",
|
||||
"ga": "Irish",
|
||||
"it": "Italian",
|
||||
"ja": "Japanese",
|
||||
"jw": "Javanese",
|
||||
"kn": "Kannada",
|
||||
"kk": "Kazakh",
|
||||
"km": "Khmer",
|
||||
"ko": "Korean",
|
||||
"ku": "Kurdish (Kurmanji)",
|
||||
"ky": "Kyrgyz",
|
||||
"lo": "Lao",
|
||||
"la": "Latin",
|
||||
"lv": "Latvian",
|
||||
"lt": "Lithuanian",
|
||||
"lb": "Luxembourgish",
|
||||
"mk": "Macedonian",
|
||||
"mg": "Malagasy",
|
||||
"ms": "Malay",
|
||||
"ml": "Malayalam",
|
||||
"mt": "Maltese",
|
||||
"mi": "Maori",
|
||||
"mr": "Marathi",
|
||||
"mn": "Mongolian",
|
||||
"my": "Myanmar (Burmese)",
|
||||
"ne": "Nepali",
|
||||
"no": "Norwegian",
|
||||
"ps": "Pashto",
|
||||
"fa": "Persian",
|
||||
"pl": "Polish",
|
||||
"pt": "Portuguese",
|
||||
"ma": "Punjabi",
|
||||
"ro": "Romanian",
|
||||
"ru": "Russian",
|
||||
"sm": "Samoan",
|
||||
"gd": "Scots Gaelic",
|
||||
"sr": "Serbian",
|
||||
"st": "Sesotho",
|
||||
"sn": "Shona",
|
||||
"sd": "Sindhi",
|
||||
"si": "Sinhala",
|
||||
"sk": "Slovak",
|
||||
"sl": "Slovenian",
|
||||
"so": "Somali",
|
||||
"es": "Spanish",
|
||||
"su": "Sudanese",
|
||||
"sw": "Swahili",
|
||||
"sv": "Swedish",
|
||||
"tg": "Tajik",
|
||||
"ta": "Tamil",
|
||||
"te": "Telugu",
|
||||
"th": "Thai",
|
||||
"tr": "Turkish",
|
||||
"uk": "Ukrainian",
|
||||
"ur": "Urdu",
|
||||
"uz": "Uzbek",
|
||||
"vi": "Vietnamese",
|
||||
"cy": "Welsh",
|
||||
"xh": "Xhosa",
|
||||
"yi": "Yiddish",
|
||||
"yo": "Yoruba",
|
||||
"zu": "Zulu"
|
||||
"yi": "Yiddish"
|
||||
};
|
||||
|
||||
module.exports = class TranslateCommand extends commando.Command {
|
||||
@@ -115,7 +77,7 @@ module.exports = class TranslateCommand extends commando.Command {
|
||||
group: 'textedit',
|
||||
memberName: 'translate',
|
||||
description: 'Translates text to a given language. (;translate ja Give me the money!)',
|
||||
details: '**Codes:** af: Afrikaans, sq: Albanian, ar: Arabic, hy: Armenian, az: Azerbaijani, eu: Basque, be: Belarusian, bn: Bengali, bs: Bosnian, bg: Bulgarian, ca: Catalan, ceb: Cebuano, ny: Chichewa, zh-cn: Chinese Simplified, zh-tw: Chinese Traditional, co: Corsican, hr: Croatian, cs: Czech, da: Danish, nl: Dutch, en: English, eo: Esperanto, et: Estonian, tl: Filipino, fi: Finnish, fr: French, fy: Frisian, gl: Galician, ka: Georgian, de: German, el: Greek, gu: Gujarati, ht: Haitian Creole, ha: Hausa, haw: Hawaiian, iw: Hebrew, hi: Hindi, hmn: Hmong, hu: Hungarian, is: Icelandic, ig: Igbo, id: Indonesian, ga: Irish, it: Italian, ja: Japanese, jw: Javanese, kn: Kannada, kk: Kazakh, km: Khmer, ko: Korean, ku: Kurdish (Kurmanji), ky: Kyrgyz, lo: Lao, la: Latin, lv: Latvian, lt: Lithuanian, lb: Luxembourgish, mk: Macedonian, mg: Malagasy, ms: Malay, ml: Malayalam, mt: Maltese, mi: Maori, mr: Marathi, mn: Mongolian, my: Myanmar (Burmese), ne: Nepali, no: Norwegian, ps: Pashto, fa: Persian, pl: Polish, pt: Portuguese, ma: Punjabi, ro: Romanian, ru: Russian, sm: Samoan, gd: Scots Gaelic, sr: Serbian, st: Sesotho, sn: Shona, sd: Sindhi, si: Sinhala, sk: Slovak, sl: Slovenian, so: Somali, es: Spanish, su: Sudanese, sw: Swahili, sv: Swedish, tg: Tajik, ta: Tamil, te: Telugu, th: Thai, tr: Turkish, uk: Ukrainian, ur: Urdu, uz: Uzbek, vi: Vietnamese, cy: Welsh, xh: Xhosa, yi: Yiddish, yo: Yoruba, zu: Zulu',
|
||||
details: '**Codes:** af: Afrikaans, sq: Albanian, ar: Arabic, az: Azerbaijani, eu: Basque, bn: Bengali, be: Belarusian, bg: Bulgarian, ca: Catalan, zh-cn: Chinese Simplified, zh-tw: Chinese Traditional, hr: Croatian, cs: Czech, da: Danish, nl: Dutch, en: English, eo: Esperanto, et: Estonian, tl: Filipino, fi: Finnish, fr: French, gl: Galician, ka: Georgian, de: German, el: Greek, gu: Gujarati, ht: Haitian Creole, iw: Hebrew, hi: Hindi, hu: Hungarian, is: Icelandic, id: Indonesian, ga: Irish, it: Italian, ja: Japanese, kn: Kannada, ko: Korean, la: Latin, lv: Latvian, lt: Lithuanian, mk: Macedonian, ms: Malay, mt: Maltese, no: Norwegian, fa: Persian, pl: Polish, pt: Portuguese, ro: Romanian, ru: Russian, gd: Scots Gaelic, sr: Serbian, sk: Slovak, sl: Slovenian, es: Spanish, sw: Swahili, sv: Swedish, ta: Tamil, te: Telugu, th: Thai, tr: Turkish, uk: Ukrainian, ur: Urdu, vi: Vietnamese, cy: Welsh, yi: Yiddish',
|
||||
examples: [';translate ja Give me the the money!'],
|
||||
args: [{
|
||||
key: 'to',
|
||||
@@ -149,16 +111,24 @@ module.exports = class TranslateCommand extends commando.Command {
|
||||
const languageto = args.to.toLowerCase();
|
||||
const thingToTranslate = args.text;
|
||||
try {
|
||||
const res = await translate(thingToTranslate, {
|
||||
to: languageto
|
||||
});
|
||||
const languagefrom = res.from.language.iso.toLowerCase();
|
||||
const response = await request
|
||||
.get('https://translate.googleapis.com/translate_a/single')
|
||||
.query({
|
||||
client: 'gtx',
|
||||
sl: 'auto',
|
||||
tl: languageto,
|
||||
dt: 't',
|
||||
q: thingToTranslate
|
||||
});
|
||||
const data = JSON.parse(response.text);
|
||||
const translated = data[0][0][0];
|
||||
const languagefrom = data[8][3][0];
|
||||
const embed = new Discord.RichEmbed()
|
||||
.setColor(0x00AE86)
|
||||
.addField(`Input (From: ${languages[languagefrom]}):`,
|
||||
thingToTranslate)
|
||||
.addField(`Translation (To: ${languages[languageto]}):`,
|
||||
res.text);
|
||||
translated);
|
||||
return message.embed(embed);
|
||||
}
|
||||
catch (err) {
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
<li><a href="https://github.com/Gawdl3y/discord.js-commando/">discord.js-commando</a></li>
|
||||
<li><a href="https://github.com/oliver-moran/jimp">JIMP</a></li>
|
||||
<li><a href="https://github.com/mikewesthad/pirate-speak">pirate-speak</a></li>
|
||||
<li><a href="https://github.com/matheuss/google-translate-api">google-translate-api</a></li>
|
||||
<li><a href="https://github.com/clux/zalgolize">zalgoize</a></li>
|
||||
<li><a href="https://github.com/lovell/hepburn">hepburn</a></li>
|
||||
<li><a href="https://github.com/visionmedia/superagent">superagent</a></li>
|
||||
|
||||
@@ -67,7 +67,6 @@
|
||||
<li><a href="https://github.com/Gawdl3y/discord.js-commando/">discord.js-commando</a></li>
|
||||
<li><a href="https://github.com/oliver-moran/jimp">JIMP</a></li>
|
||||
<li><a href="https://github.com/mikewesthad/pirate-speak">pirate-speak</a></li>
|
||||
<li><a href="https://github.com/matheuss/google-translate-api">google-translate-api</a></li>
|
||||
<li><a href="https://github.com/clux/zalgolize">zalgoize</a></li>
|
||||
<li><a href="https://github.com/lovell/hepburn">hepburn</a></li>
|
||||
<li><a href="https://github.com/visionmedia/superagent">superagent</a></li>
|
||||
|
||||
@@ -35,13 +35,14 @@ client.on('guildCreate', async(guild) => {
|
||||
console.log(`[Guild] I have joined the guild: ${guild.name}, Owned by: ${guild.owner.user.username} (${guild.id})!`);
|
||||
client.guilds.get(process.env.SERVER_ID).channels.get(process.env.ANNOUNCEMENT_CHANNEL_ID).send(`I have joined the server: ${guild.name}, Owned by: ${guild.owner.user.username} (${guild.id})!`);
|
||||
const results = await client.shard.fetchClientValues('guilds.size');
|
||||
console.log(`[Guild Count] ${results.reduce((prev, val) => prev + val, 0)}`);
|
||||
const count = results.reduce((prev, val) => prev + val, 0);
|
||||
console.log(`[Guild Count] ${count}`);
|
||||
try {
|
||||
const response = await request
|
||||
.post('https://www.carbonitex.net/discord/data/botdata.php')
|
||||
.send({
|
||||
key: process.env.CARBON_KEY,
|
||||
servercount: results.reduce((prev, val) => prev + val, 0)
|
||||
servercount: count
|
||||
});
|
||||
console.log(`[Carbon] Successfully posted to Carbon. ${response.text}`);
|
||||
}
|
||||
@@ -55,7 +56,7 @@ client.on('guildCreate', async(guild) => {
|
||||
'Authorization': process.env.DISCORD_BOTS_KEY
|
||||
})
|
||||
.send({
|
||||
server_count: results.reduce((prev, val) => prev + val, 0)
|
||||
server_count: count
|
||||
});
|
||||
console.log(`[Discord Bots] Successfully posted to Discord Bots. ${response.body.stats[0].server_count}`);
|
||||
}
|
||||
@@ -68,13 +69,14 @@ client.on('guildDelete', async(guild) => {
|
||||
console.log(`[Guild] I have left the guild: ${guild.name}, Owned by: ${guild.owner.user.username} (${guild.id})...`);
|
||||
client.guilds.get(process.env.SERVER_ID).channels.get(process.env.ANNOUNCEMENT_CHANNEL_ID).send(`I have left the server: ${guild.name}, Owned by: ${guild.owner.user.username} (${guild.id})...`);
|
||||
const results = await client.shard.fetchClientValues('guilds.size');
|
||||
console.log(`[Guild Count] ${results.reduce((prev, val) => prev + val, 0)}`);
|
||||
const count = results.reduce((prev, val) => prev + val, 0);
|
||||
console.log(`[Guild Count] ${count}`);
|
||||
try {
|
||||
const response = await request
|
||||
.post('https://www.carbonitex.net/discord/data/botdata.php')
|
||||
.send({
|
||||
key: process.env.CARBON_KEY,
|
||||
servercount: results.reduce((prev, val) => prev + val, 0)
|
||||
servercount: count
|
||||
});
|
||||
console.log(`[Carbon] Successfully posted to Carbon. ${response.text}`);
|
||||
}
|
||||
@@ -88,7 +90,7 @@ client.on('guildDelete', async(guild) => {
|
||||
'Authorization': process.env.DISCORD_BOTS_KEY
|
||||
})
|
||||
.send({
|
||||
server_count: results.reduce((prev, val) => prev + val, 0)
|
||||
server_count: count
|
||||
});
|
||||
console.log(`[Discord Bots] Successfully posted to Discord Bots. ${response.body.stats[0].server_count}`);
|
||||
}
|
||||
|
||||
+1
-2
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiaobot",
|
||||
"version": "20.0.1",
|
||||
"version": "20.1.0",
|
||||
"description": "A Discord Bot",
|
||||
"main": "shardingmanager.js",
|
||||
"repository": {
|
||||
@@ -20,7 +20,6 @@
|
||||
"cowsay": "^1.1.9",
|
||||
"discord.js": "hydrabolt/discord.js",
|
||||
"discord.js-commando": "gawdl3y/discord.js-commando",
|
||||
"google-translate-api": "^2.2.2",
|
||||
"hepburn": "^1.0.0",
|
||||
"jimp": "^0.2.27",
|
||||
"mathjs": "^3.11.0",
|
||||
|
||||
Reference in New Issue
Block a user