Local Pokemon Cries

This commit is contained in:
Dragon Fire
2020-10-30 19:31:44 -04:00
parent fbf2a1d8f4
commit bafdacce93
900 changed files with 69 additions and 53 deletions
+2 -13
View File
@@ -1,4 +1,5 @@
const request = require('node-superfetch');
const path = require('path');
const { removeDuplicates, firstUpperCase } = require('../../util/Util');
const missingno = require('../../assets/json/missingno');
@@ -37,7 +38,7 @@ module.exports = class Pokemon {
};
this.typesCached = data.missingno || false;
this.missingno = data.missingno || false;
this.cry = null;
this.cry = path.join(__dirname, '..', '..', 'assets', 'sounds', 'pokedex', `${data.id}.wav`);
}
get displayID() {
@@ -109,16 +110,4 @@ module.exports = class Pokemon {
}
return this.chain.data;
}
async fetchCry() {
if (this.cry) return this.cry;
if (this.missingno) return null;
try {
const { body } = await request.get(`https://pokemoncries.com/cries/${this.id}.mp3`);
this.cry = body;
return this.cry;
} catch {
return null;
}
}
};