import fetch from "flumm-fetch-cookies"; import config from "../../../cfg/config.json"; const api = `http://ws.audioscrobbler.com/2.0/?method=user.getRecentTracks&limit=1&api_key=${config.apis.lastfm.key}&format=json&user=`; export default async bot => { return [{ name: "lastfm", call: /^(\.|\/)np/i, set: "uwe", /*help: { text: "", usage: "[b].np[/b] [i][/i]" },*/ f: async e => { const nick = e.args[0] || e.user.nick; let res = await (await fetch(`${api}${nick}`)).json(); if(res.error) return e.reply("User not found"); res = res.recenttracks; const track = res.track[0]; const info = { user: res["@attr"].user, track: `${track.artist["#text"]} - ${track.name}`, playing: track["@attr"] ? true : false }; return e.reply(info.playing ? `[b]${info.user}[/b] is listening to [b]${info.track}[/b]` : `[b]${info.user}[/b] is not listening to anything. They last listened to [b]${info.track}[/b]`); } }]; };