I was trying to make a little boop command on my discord rpc but it ended up that using setInterval to get an updated version of the rpc ended up adding boops++; since it was calling the URL function
any ideas on how to make it not call the function but keep everything working and updated? Is there a better alternative to setInterval?
var rpc = require("discord-rpc")
var fetch = require("node-fetch")
const client = new rpc.Client({
transport: 'ipc'
})
let boops = 0
function url() {
boops++;
return "https://i.pinimg.com/originals/32/04/c5/3204c53493fcb595a5a87427f2d6cf71.gif"
}
client.on('ready', () => {
client.request('SET_ACTIVITY', {
pid: process.pid,
activity: {
details: `zoe hash been booped`,
state: `${boops} times`,
assets: {
large_image: "image",
large_text: "Nya~!" // THIS WILL SHOW AS "Playing <Status>" from the outisde
},
buttons: [{
label: "Boop zoe✨",
url: url()
}],
}
})
// activity can only be set every 15 seconds
setInterval(() => {
client.request('SET_ACTIVITY', {
pid: process.pid,
activity: {
details: `zoe hash been booped`,
state: `${boops} times`,
assets: {
large_image: "image",
large_text: "Nya~!" // THIS WILL SHOW AS "Playing <Status>" from the outisde
},
buttons: [{
label: "Boop zoe✨",
url: url()
}],
}
})
}, 15e3);
});
client.login({
clientId: "828106833251663912"
}).catch(console.error);