mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-18 05:49:49 +02:00
Allow a number of language codes in itunes
This commit is contained in:
@@ -403,6 +403,10 @@
|
|||||||
"quote": "You’ve got mountains of your own, I’ll bet on it. Take heart. Be encouraged. Remain steadfast. Hang on for dear life. You’ve got a better grip than you realize.",
|
"quote": "You’ve got mountains of your own, I’ll bet on it. Take heart. Be encouraged. Remain steadfast. Hang on for dear life. You’ve got a better grip than you realize.",
|
||||||
"author": "Adam Young"
|
"author": "Adam Young"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"quote": "I did not have sexual relations with that woman.",
|
||||||
|
"author": "Bill Clinton"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"quote": "Eat pant.",
|
"quote": "Eat pant.",
|
||||||
"author": "Dragon Fire"
|
"author": "Dragon Fire"
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
const { Command } = require('discord.js-commando');
|
const { Command } = require('discord.js-commando');
|
||||||
const { MessageEmbed } = require('discord.js');
|
const { MessageEmbed } = require('discord.js');
|
||||||
const snekfetch = require('snekfetch');
|
const snekfetch = require('snekfetch');
|
||||||
const { list } = require('../../util/Util');
|
|
||||||
const countries = ['us', 'jp'];
|
|
||||||
|
|
||||||
module.exports = class ITunesCommand extends Command {
|
module.exports = class ITunesCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -12,16 +10,13 @@ module.exports = class ITunesCommand extends Command {
|
|||||||
group: 'search',
|
group: 'search',
|
||||||
memberName: 'itunes',
|
memberName: 'itunes',
|
||||||
description: 'Searches iTunes for your query.',
|
description: 'Searches iTunes for your query.',
|
||||||
|
details: '**Codes**: <https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes>',
|
||||||
clientPermissions: ['EMBED_LINKS'],
|
clientPermissions: ['EMBED_LINKS'],
|
||||||
args: [
|
args: [
|
||||||
{
|
{
|
||||||
key: 'country',
|
key: 'country',
|
||||||
prompt: `What country should results be obtained for? Either ${list(countries, 'or')}.`,
|
prompt: 'What country code should results be obtained for?',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
validate: country => {
|
|
||||||
if (countries.includes(country.toLowerCase())) return true;
|
|
||||||
return `Invalid country, please enter either ${list(countries, 'or')}.`;
|
|
||||||
},
|
|
||||||
parse: country => country.toLowerCase()
|
parse: country => country.toLowerCase()
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -64,6 +59,9 @@ module.exports = class ITunesCommand extends Command {
|
|||||||
data.primaryGenreName, true);
|
data.primaryGenreName, true);
|
||||||
return msg.embed(embed);
|
return msg.embed(embed);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
if (err.status === 500) {
|
||||||
|
return msg.reply('Invalid country code. Refer to <https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes>.');
|
||||||
|
}
|
||||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,10 @@ class Util {
|
|||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static formatNumber(number, dollar = false) {
|
||||||
|
return `${dollar ? '$' : ''}${number.toLocaleString('en-US', { maximumFractionDigits: 2 })}`;
|
||||||
|
}
|
||||||
|
|
||||||
static cleanXML(text) {
|
static cleanXML(text) {
|
||||||
return text
|
return text
|
||||||
.replace(/<br \/>/g, '')
|
.replace(/<br \/>/g, '')
|
||||||
|
|||||||
Reference in New Issue
Block a user