Simple fixes on lastfm.js

This commit is contained in:
Lucas Gabriel 2024-09-10 17:52:47 -03:00
parent 4b1d1de779
commit 66dff8ceb3
No known key found for this signature in database
GPG Key ID: D9B075FC6DC93985

View File

@ -54,9 +54,8 @@ module.exports = (bot) => {
const artistUrl = `https://www.last.fm/music/${encodeURIComponent(artistName)}`;
const userUrl = `https://www.last.fm/user/${encodeURIComponent(lastfmUser)}`;
// Requesting the number of plays of last song
let num_plays = '';
try{
try {
const response_plays = await axios.get(scrobbler_url, {
params: {
method: 'track.getInfo',
@ -71,9 +70,12 @@ module.exports = (bot) => {
}
});
num_plays = response_plays.data.track.userplaycount;
}catch (err){
} catch (err) {
console.log(err)
ctx.reply('Error!', {
const message = Strings.lastFmErr
.replace("{lastfmUser}", `[${lastfmUser}](${userUrl})`)
.replace("{err}", err);
ctx.reply(message, {
parse_mode: "Markdown",
reply_to_message_id: ctx.message.message_id
});
@ -84,8 +86,7 @@ module.exports = (bot) => {
.replace("{nowPlaying}", nowPlaying)
.replace("{trackName}", `[${trackName}](${trackUrl})`)
.replace("{artistName}", `[${artistName}](${artistUrl})`)
.replace("{plays}", `${num_plays}`)
;
.replace("{plays}", `${num_plays}`);
if (imageUrl) {
ctx.replyWithPhoto(imageUrl, {
@ -99,7 +100,6 @@ module.exports = (bot) => {
reply_to_message_id: ctx.message.message_id
});
};
} catch (err) {
const userUrl = `https://www.last.fm/user/${encodeURIComponent(lastfmUser)}`;
const message = Strings.lastFmErr