/battlefactory: Fix searching for nonexistent tiers (#7989)

* BF cmd: Fix crash searching for a valid tier not included in a specific gen

* Update server/chat-plugins/random-battles.ts

* Update server/chat-plugins/random-battles.ts

* Update server/chat-plugins/random-battles.ts

Co-authored-by: Kris Johnson <11083252+KrisXV@users.noreply.github.com>
This commit is contained in:
Instruct
2021-02-02 23:56:08 -05:00
committed by GitHub
parent 3835c3cfeb
commit 7989e4df4f

View File

@@ -102,6 +102,9 @@ function battleFactorySets(species: string | Species, tier: string | null, gen =
if (!isBSS) {
if (!tier) return {e: `Please provide a valid tier.`};
if (!(toID(tier) in TIERS)) return {e: `That tier isn't supported.`};
if (['Mono', 'LC'].includes(TIERS[toID(tier)]) && genNum < 7) {
return {e: `${TIERS[toID(tier)]} is not included in [Gen ${genNum}] Battle Factory.`};
}
const t = statsFile[TIERS[toID(tier)]];
if (!(species.id in t)) {
const formatName = Dex.getFormat(`${gen}battlefactory`).name;