mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
24 lines
579 B
JavaScript
24 lines
579 B
JavaScript
const Argument = require('../framework/ArgumentType');
|
|
const examples = ['Pikachu', 'Bulbasaur', 'Victini', 'Flygon'];
|
|
|
|
module.exports = class PokemonArgument extends Argument {
|
|
constructor(client) {
|
|
super(client, 'pokemon');
|
|
}
|
|
|
|
async validate(value) {
|
|
const data = await this.client.pokemon.fetch(value);
|
|
if (!data) return false;
|
|
return true;
|
|
}
|
|
|
|
parse(value) {
|
|
return this.client.pokemon.fetch(value);
|
|
}
|
|
|
|
example() {
|
|
if (this.client.pokemon.size) return this.client.pokemon.random().name;
|
|
return examples[Math.floor(Math.random() * examples.length)];
|
|
}
|
|
};
|