mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
Add song short name to guess-song
This commit is contained in:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user