hey i wanna do something on discord.js but just don't know how, i know that it's possible but idk how so i wanted to ask ya guys that: i wanna set my bot's activity like it's keep being changed respectively not randomly. it shouldn't be randomly because....uhhh....you'll realize soon ._.
here's my activity's codes but it's in randomly(i want it to be respectively as i said):
client.on("ready") {
console.log('Boom bot is ready to boom!')
setInterval(() => {
var v = (client.guilds.cache.size)
const count = [
"1", "2", "3", "BOOM!"]
// here it collects the titles in randomly
const number = Math.floor(Math.random()*(count.length))
const activity = count[number]
client.user.setActivity(activity);
};
})
if anybody here knows how to get the numbers of number variable respectively, plz consider helping this guy👍🏻
Try a couple things: declare the desired statuses outside of the setInterval function. Also set an interval in ms for the interval to execute on. This is done by adding a comma and then the number of milliseconds to wait before executing again. Declare the desired index outside of the function and then inside the function reset the index to zero once you've iterated through the whole array.
const count = ["1", "2", "3", "BOOM!"] //removed outside
let index = 0; //declaring an index
setInterval(() => {
// here it collects the titles in randomly
const activity = count[index] //accessing array at index
index++; //incrementing
if (index >= count.length) index = 0; //resetting
console.log(activity);
}, 1000); //setting an interval