Add song short name to guess-song

This commit is contained in:
Dragon Fire
2021-05-02 11:11:47 -04:00
parent 67287b5220
commit e3476bf855
+12 -1
View File
@@ -75,7 +75,7 @@ module.exports = class GuessSongCommand extends Command {
this.client.dispatchers.delete(msg.guild.id);
if (!msgs.size) return msg.reply(`Time! It's **${data.name}** by **${data.artist}**!`);
const guess = msgs.first().content.toLowerCase();
if (!guess.includes(data.name.toLowerCase())) {
if (!guess.includes(data.name.toLowerCase()) && !guess.includes(data.shortName.toLowerCase())) {
return msg.reply(`Nope! It's **${data.name}** by **${data.artist}**!`);
}
return msg.reply(`Nice! It's **${data.name}** by **${data.artist}**!`);
@@ -119,6 +119,7 @@ module.exports = class GuessSongCommand extends Command {
const result = {
id,
name: body.name,
shortName: await this.shortTrackName(body.name),
artist: list(body.artists.map(artist => artist.name)),
preview: previewURL
};
@@ -132,6 +133,16 @@ module.exports = class GuessSongCommand extends Command {
return JSON.parse(decodeURIComponent($('script[id="resource"]')[0].children[0].data)).preview_url;
}
async shortTrackName(longName) {
const { body } = await request
.get('https://demaster.hankapi.com/demaster')
.query({
long_track_name: longName,
format: 'json'
});
return body.short_track_name;
}
async fetchToken() {
const { body } = await request
.post('https://accounts.spotify.com/api/token')