From 36e343a6d8b38be76d2dc771602b68dfeebc1f00 Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Tue, 19 May 2020 12:24:27 -0400 Subject: [PATCH] Add Region Picking to Akinator --- assets/json/akinator.json | 25 +++++++++++++++++++++++++ commands/games-sp/akinator.js | 18 +++++++++++++++--- package.json | 2 +- 3 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 assets/json/akinator.json diff --git a/assets/json/akinator.json b/assets/json/akinator.json new file mode 100644 index 00000000..355b5a3e --- /dev/null +++ b/assets/json/akinator.json @@ -0,0 +1,25 @@ +[ + "en", + "en_object", + "en_animals", + "ar", + "cn", + "de", + "de_animals", + "es", + "es_animals", + "fr", + "fr_objects", + "fr_animals", + "il", + "it", + "it_animals", + "jp", + "jp_animals", + "kr", + "nl", + "pl", + "pt", + "ru", + "tr" +] diff --git a/commands/games-sp/akinator.js b/commands/games-sp/akinator.js index ef4c8ddf..697148f2 100644 --- a/commands/games-sp/akinator.js +++ b/commands/games-sp/akinator.js @@ -2,7 +2,8 @@ const Command = require('../../structures/Command'); const { MessageEmbed } = require('discord.js'); const Aki = require('aki-api'); const { stripIndents } = require('common-tags'); -const { verify } = require('../../util/Util'); +const { list, verify } = require('../../util/Util'); +const regions = require('../../assets/json/akinator'); module.exports = class AkinatorCommand extends Command { constructor(client) { @@ -12,6 +13,7 @@ module.exports = class AkinatorCommand extends Command { group: 'games-sp', memberName: 'akinator', description: 'Think about a real or fictional character, I will try to guess who it is.', + details: `**Regions:** ${regions.join(', ')}`, clientPermissions: ['EMBED_LINKS'], credit: [ { @@ -19,15 +21,25 @@ module.exports = class AkinatorCommand extends Command { url: 'https://en.akinator.com/', reason: 'API' } + ], + args: [ + { + key: 'region', + prompt: `What region do you want to use? Either ${list(regions, 'or')}.`, + type: 'string', + default: 'en', + oneOf: regions, + parse: region => region.toLowerCase() + } ] }); } - async run(msg) { + async run(msg, { region }) { const current = this.client.games.get(msg.channel.id); if (current) return msg.reply(`Please wait until the current game of \`${current.name}\` is finished.`); try { - const aki = new Aki('en'); + const aki = new Aki(region); let ans = null; let win = false; let timesGuessed = 0; diff --git a/package.json b/package.json index 61932a2f..97a7886d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "114.16.1", + "version": "114.16.2", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {