import fetch from "../fetch"; import { cfg } from "../../inc/cfg"; export default bot => { bot._trigger.set("scrnd", new bot.trigger({ call: /^(\.|\/)scrnd/i, set: "uwe", help: { text: "get random track from Flummi's soundcloud favorites", usage: "[b].scrnd[/b]" }, f: e => { fetch(`http://api.soundcloud.com/users/${cfg.main.soundcloud.val.user}/favorites?client_id=${cfg.main.soundcloud.val.clientid}`) .then(res => res.json()) .then(res => { const track = res[~~((Math.random() * res.length) + 1)]; e.reply(`${track.permalink_url}\n[b]${track.title}[/b] - length [b]${track.duration}[/b] - [b]${track.user.username}[/b] on [b]${track.created_at}[/b]`); }).catch(err => console.log(err)); } })); };