mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-25 06:42:51 +02:00
Moveset Version
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const { MessageEmbed } = require('discord.js');
|
const { MessageEmbed } = require('discord.js');
|
||||||
const { stripIndents } = require('common-tags');
|
const versions = {
|
||||||
|
'red-blue': 'Red and Blue',
|
||||||
|
'ultra-sun-ultra-moon': 'Ultra Sun and Ultra Moon'
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = class PokedexMovesetCommand extends Command {
|
module.exports = class PokedexMovesetCommand extends Command {
|
||||||
constructor(client) {
|
constructor(client) {
|
||||||
@@ -57,7 +60,8 @@ module.exports = class PokedexMovesetCommand extends Command {
|
|||||||
.setColor(0xED1C24)
|
.setColor(0xED1C24)
|
||||||
.setAuthor(`#${data.displayID} - ${data.name}`, data.boxImageURL, data.serebiiURL)
|
.setAuthor(`#${data.displayID} - ${data.name}`, data.boxImageURL, data.serebiiURL)
|
||||||
.setDescription(data.moveSet.map(move => `**Level ${move.level}:** ${move.name}`).join('\n'))
|
.setDescription(data.moveSet.map(move => `**Level ${move.level}:** ${move.name}`).join('\n'))
|
||||||
.setThumbnail(data.spriteImageURL);
|
.setThumbnail(data.spriteImageURL)
|
||||||
|
.setFooter(`Moveset data taken from ${versions[pokemon.moveSetVersion]}.`);
|
||||||
return msg.embed(embed);
|
return msg.embed(embed);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
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!`);
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ module.exports = class Pokemon {
|
|||||||
this.height = data.missingno ? data.height : null;
|
this.height = data.missingno ? data.height : null;
|
||||||
this.weight = data.missingno ? data.weight : null;
|
this.weight = data.missingno ? data.weight : null;
|
||||||
this.moveSet = data.missingno ? data.moveSet : [];
|
this.moveSet = data.missingno ? data.moveSet : [];
|
||||||
|
this.moveSetVersion = data.missingno ? 'red-blue' : 'ultra-sun-ultra-moon';
|
||||||
this.gameDataCached = data.missingno || false;
|
this.gameDataCached = data.missingno || false;
|
||||||
this.missingno = data.missingno || false;
|
this.missingno = data.missingno || false;
|
||||||
this.cry = data.id > store.pokemonCountWithCry
|
this.cry = data.id > store.pokemonCountWithCry
|
||||||
@@ -111,11 +112,12 @@ module.exports = class Pokemon {
|
|||||||
spd: defaultBody.stats.find(stat => stat.stat.name === 'speed').base_stat
|
spd: defaultBody.stats.find(stat => stat.stat.name === 'speed').base_stat
|
||||||
};
|
};
|
||||||
for (const move of defaultBody.moves) {
|
for (const move of defaultBody.moves) {
|
||||||
if (!move.version_group_details[move.version_group_details.length - 1].level_learned_at) continue;
|
const versionGroup = move.version_group_details.find(version => version.name === this.moveSetVersion);
|
||||||
|
if (!versionGroup.level_learned_at) continue;
|
||||||
const { body: moveBody } = await request.get(move.move.url);
|
const { body: moveBody } = await request.get(move.move.url);
|
||||||
this.moveSet.push({
|
this.moveSet.push({
|
||||||
name: moveBody.names.find(name => name.language.name === 'en').name,
|
name: moveBody.names.find(name => name.language.name === 'en').name,
|
||||||
level: move.version_group_details[move.version_group_details.length - 1].level_learned_at
|
level: versionGroup.level_learned_at
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.moveSet = this.moveSet.sort((a, b) => a.level - b.level);
|
this.moveSet = this.moveSet.sort((a, b) => a.level - b.level);
|
||||||
|
|||||||
Reference in New Issue
Block a user