diff --git a/assets/json/currency.json b/assets/json/currency.json index c5d5599f..06fe2787 100644 --- a/assets/json/currency.json +++ b/assets/json/currency.json @@ -1,34 +1,34 @@ [ - "aud", - "usd", - "bgn", - "brl", - "cad", - "chf", - "cny", - "czk", - "dkk", - "gbp", - "hkd", - "hrk", - "huf", - "idr", - "ils", - "inr", - "jpy", - "krw", - "mxn", - "myr", - "nok", - "nzd", - "php", - "pln", - "ron", - "rub", - "sek", - "sgd", - "thb", - "try", - "zar", - "eur" + "AUD", + "USD", + "BGN", + "BRL", + "CAD", + "CHF", + "CNY", + "CZK", + "DKK", + "GBP", + "HKD", + "HRK", + "HUF", + "IDR", + "ILS", + "INR", + "JPY", + "KRW", + "MXN", + "MYR", + "NOK", + "NZD", + "PHP", + "PLN", + "RON", + "RUB", + "SEK", + "SGD", + "THB", + "TRY", + "ZAR", + "EUR" ] diff --git a/commands/avatar-edit/hat.js b/commands/avatar-edit/hat.js index 770300bf..8afa9b51 100644 --- a/commands/avatar-edit/hat.js +++ b/commands/avatar-edit/hat.js @@ -22,8 +22,12 @@ module.exports = class HatCommand extends Command { { key: 'type', prompt: `What type of hat would you like to use? Either ${list(hats, 'or')}.`, - type: 'choice', - choices: hats + type: 'string', + validate: type => { + if (hats.includes(type.toLowerCase())) return true; + return `Invalid type, please enter either ${list(hats, 'or')}.`; + }, + parse: type => type.toLowerCase() }, { key: 'user', diff --git a/commands/events/horoscope.js b/commands/events/horoscope.js index c402aae6..83635114 100644 --- a/commands/events/horoscope.js +++ b/commands/events/horoscope.js @@ -17,8 +17,12 @@ module.exports = class HoroscopeCommand extends Command { { key: 'sign', prompt: `Which sign would you like to get the horoscope for? Either ${list(signs, 'or')}.`, - type: 'choice', - choices: signs + type: 'string', + validate: sign => { + if (signs.includes(sign.toLowerCase())) return true; + return `Invalid sign, please enter either ${list(signs, 'or')}.`; + }, + parse: sign => sign.toLowerCase() } ] }); diff --git a/commands/games/math-quiz.js b/commands/games/math-quiz.js index 7bb419f3..02c85902 100644 --- a/commands/games/math-quiz.js +++ b/commands/games/math-quiz.js @@ -24,8 +24,12 @@ module.exports = class MathQuizCommand extends Command { { key: 'difficulty', prompt: `What should the difficulty of the game be? Either ${list(difficulties, 'or')}.`, - type: 'choice', - choices: difficulties + type: 'string', + validate: difficulty => { + if (difficulties.includes(difficulty.toLowerCase())) return true; + return `Invalid difficulty, please enter either ${list(difficulties, 'or')}.`; + }, + parse: difficulty => difficulty.toLowerCase() } ] }); diff --git a/commands/games/quiz.js b/commands/games/quiz.js index ffd88a38..b3a34fdb 100644 --- a/commands/games/quiz.js +++ b/commands/games/quiz.js @@ -22,16 +22,24 @@ module.exports = class QuizCommand extends Command { { key: 'type', prompt: `Which type of question would you like to have? Either ${list(types, 'or')}.`, - type: 'choice', + type: 'string', default: 'multiple', - choices: types + validate: type => { + if (types.includes(type.toLowerCase())) return true; + return `Invalid type, please enter either ${list(types, 'or')}.`; + }, + parse: type => type.toLowerCase() }, { key: 'difficulty', prompt: `What should the difficulty of the game be? Either ${list(difficulties, 'or')}.`, - type: 'choice', + type: 'string', default: '', - choices: difficulties + validate: difficulty => { + if (difficulties.includes(difficulty.toLowerCase())) return true; + return `Invalid difficulty, please enter either ${list(difficulties, 'or')}.`; + }, + parse: difficulty => difficulty.toLowerCase() } ] }); diff --git a/commands/games/rock-paper-scissors.js b/commands/games/rock-paper-scissors.js index 3542453b..99397845 100644 --- a/commands/games/rock-paper-scissors.js +++ b/commands/games/rock-paper-scissors.js @@ -13,8 +13,8 @@ module.exports = class RockPaperScissorsCommand extends Command { { key: 'choice', prompt: 'Rock, Paper, or Scissors?', - type: 'choice', - choices + type: 'string', + parse: choice => choice.toLowerCase() } ] }); diff --git a/commands/games/typing-test.js b/commands/games/typing-test.js index 8d03e3e0..284ed17d 100644 --- a/commands/games/typing-test.js +++ b/commands/games/typing-test.js @@ -24,8 +24,12 @@ module.exports = class TypingTestCommand extends Command { { key: 'difficulty', prompt: `What should the difficulty of the game be? Either ${list(difficulties, 'or')}.`, - type: 'choice', - choices: difficulties + type: 'string', + validate: difficulty => { + if (difficulties.includes(difficulty.toLowerCase())) return true; + return `Invalid difficulty, please enter either ${list(difficulties, 'or')}.`; + }, + parse: difficulty => difficulty.toLowerCase() } ] }); diff --git a/commands/info/channel.js b/commands/info/channel.js index 41a5e0bf..d1a8590f 100644 --- a/commands/info/channel.js +++ b/commands/info/channel.js @@ -33,7 +33,7 @@ module.exports = class ChannelInfoCommand extends Command { const embed = new MessageEmbed() .setColor(0x00AE86) .addField('❯ Name', - channel.type !== 'dm' ? channel.name : `@${channel.recipient.username}`, true) + channel.name || 'None', true) .addField('❯ ID', channel.id, true) .addField('❯ NSFW', diff --git a/commands/info/emoji-list.js b/commands/info/emoji-list.js index f4252433..dc1fe096 100644 --- a/commands/info/emoji-list.js +++ b/commands/info/emoji-list.js @@ -15,9 +15,13 @@ module.exports = class EmojiListCommand extends Command { { key: 'type', prompt: `What type of emoji would you like to view? Either ${list(types, 'or')}.`, - type: 'choice', + type: 'string', default: 'regular', - choices: types + validate: type => { + if (types.includes(type.toLowerCase())) return true; + return `Invalid type, please enter either ${list(types, 'or')}.`; + }, + parse: type => type.toLowerCase() } ] }); diff --git a/commands/number-edit/currency.js b/commands/number-edit/currency.js index 0dd0c362..49aaa59c 100644 --- a/commands/number-edit/currency.js +++ b/commands/number-edit/currency.js @@ -16,14 +16,22 @@ module.exports = class CurrencyCommand extends Command { { key: 'base', prompt: `What currency code do you want to use as the base? Either ${list(codes, 'or')}.`, - type: 'choice', - choices: codes + type: 'string', + validate: base => { + if (codes.includes(base.toUpperCase())) return true; + return `Invalid base, please enter either ${list(codes, 'or')}.`; + }, + parse: base => base.toUpperCase() }, { key: 'target', prompt: `What currency code do you want to convert to? Either ${list(codes, 'or')}.`, - type: 'choice', - choices: codes + type: 'string', + validate: target => { + if (codes.includes(target.toUpperCase())) return true; + return `Invalid target, please enter either ${list(codes, 'or')}.`; + }, + parse: target => target.toUpperCase() }, { key: 'amount', diff --git a/commands/random/name.js b/commands/random/name.js index 1482d3f0..5d2656ca 100644 --- a/commands/random/name.js +++ b/commands/random/name.js @@ -15,9 +15,13 @@ module.exports = class NameCommand extends Command { { key: 'gender', prompt: `Which gender do you want to generate a name for? Either ${list(genders, 'or')}.`, - type: 'choice', + type: 'string', default: 'both', - choices: genders + validate: gender => { + if (genders.includes(gender.toLowerCase())) return true; + return `Invalid gender, please enter either ${list(genders, 'or')}.`; + }, + parse: gender => gender.toLowerCase() } ] }); diff --git a/commands/search/deviantart.js b/commands/search/deviantart.js index 928a4cdf..0ac50d58 100644 --- a/commands/search/deviantart.js +++ b/commands/search/deviantart.js @@ -16,8 +16,12 @@ module.exports = class DeviantartCommand extends Command { { key: 'section', prompt: `What section would you like to search? Either ${list(sections, 'or')}.`, - type: 'choice', - choices: sections + type: 'string', + validate: section => { + if (sections.includes(section.toLowerCase())) return true; + return `Invalid section, please enter either ${list(sections, 'or')}.`; + }, + parse: section => section.toLowerCase() }, { key: 'query', diff --git a/commands/search/urban-dictionary.js b/commands/search/urban-dictionary.js index e1cc2c96..8cf00d15 100644 --- a/commands/search/urban-dictionary.js +++ b/commands/search/urban-dictionary.js @@ -1,7 +1,7 @@ const { Command } = require('discord.js-commando'); const { MessageEmbed } = require('discord.js'); const snekfetch = require('snekfetch'); -const { shorten } = require('../../util/Util'); +const { shorten, list } = require('../../util/Util'); const types = ['random', 'top']; module.exports = class UrbanDictionaryCommand extends Command { @@ -23,9 +23,13 @@ module.exports = class UrbanDictionaryCommand extends Command { { key: 'type', prompt: 'Do you want to get the top answer or a random one?', - type: 'choice', + type: 'string', default: 'top', - choices: types + validate: type => { + if (types.includes(type.toLowerCase())) return true; + return `Invalid type, please enter either ${list(types, 'or')}.`; + }, + parse: type => type.toLowerCase() } ] }); diff --git a/commands/text-edit/base64.js b/commands/text-edit/base64.js index fc2b2a54..05592468 100644 --- a/commands/text-edit/base64.js +++ b/commands/text-edit/base64.js @@ -15,8 +15,12 @@ module.exports = class Base64Command extends Command { { key: 'mode', prompt: `Would you like to ${list(modes, 'or')}?`, - type: 'choice', - choices: modes + type: 'string', + validate: mode => { + if (modes.includes(mode.toLowerCase())) return true; + return `Invalid mode, please enter either ${list(modes, 'or')}.`; + }, + parse: mode => mode.toLowerCase() }, { key: 'text', diff --git a/commands/text-edit/binary.js b/commands/text-edit/binary.js index 50baf781..9d8056e3 100644 --- a/commands/text-edit/binary.js +++ b/commands/text-edit/binary.js @@ -14,8 +14,12 @@ module.exports = class BinaryCommand extends Command { { key: 'mode', prompt: `Would you like to ${list(modes, 'or')}?`, - type: 'choice', - choices: modes + type: 'string', + validate: mode => { + if (modes.includes(mode.toLowerCase())) return true; + return `Invalid mode, please enter either ${list(modes, 'or')}.`; + }, + parse: mode => mode.toLowerCase() }, { key: 'text', diff --git a/package.json b/package.json index 110e2123..1f8f8c5e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "69.0.1", + "version": "69.0.0", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": { diff --git a/types/choice.js b/types/choice.js deleted file mode 100644 index 91d5d5cb..00000000 --- a/types/choice.js +++ /dev/null @@ -1,19 +0,0 @@ -const { ArgumentType } = require('discord.js-commando'); -const { list } = require('../util/Util'); - -class ChoiceArgumentType extends ArgumentType { - constructor(client) { - super(client, 'choice'); - } - - validate(value, msg, arg) { - if (arg.choices.includes(value.toLowerCase())) return true; - return `Invalid ${arg.label}, please enter either ${list(arg.choices, 'or')}.`; - } - - parse(value) { - return value.toLowerCase(); - } -} - -module.exports = ChoiceArgumentType;