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