rotating status

const servers = (client.guilds.cache.size) const members = client.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0); const activities = [ 'GTA', with ${members} users, 'with AmNobCop', with ${servers} servers, 'with NotCaesahr' ]; setInterval(() => { const status = activities[Math.floor(Math.random() * activities.length)]; client.user.setPresence({ activities: [{name: ${status}}]}); }, 5000);
20 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Baconburger998
now how would i make it so it would set the status to watching if the thing was ${members} anyone wanna help
MrMythical
MrMythical2y ago
5 seconds is way too short of an interval
Baconburger998
so i figured out my first question but how would i make the ${members} update like every 20 mins. cuz rn it just gets the users from startup but then it gets out dated, is there a way to do that?
probablyraging
Fetch the members in the interval
Baconburger998
so like the const inside the interval?
probablyraging
Sure, that would work
Baconburger998
is there a better way?
probablyraging
What do you mean by "better"?
Baconburger998
setInterval(() => {
const servers = (client.guilds.cache.size)
const channels = (client.channels.cache.size)
const members = client.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0);
const activities = [
{ type: 0, name: "ROBLOX" },
{ type: 0, name: "Grand Theft Auto 5" },
{ type: 0, name: "Fortnite" },
{ type: 0, name: "Farming Simulator 19" },
{ type: 2, name: `Spotify` },
{ type: 2, name: `AmNobCop` },
{ type: 2, name: `NotCaesahr` },
{ type: 3, name: `out for commands` },
{ type: 3, name: `YouTube` },
{ type: 3, name: `${servers} servers` },
{ type: 3, name: `${channels} channels` },
{ type: 3, name: `${members} members` }
];

const status = activities[Math.floor(Math.random() * activities.length)];
client.user.setActivity({ type: status.type, name: status.name });
}, 10000);
setInterval(() => {
const servers = (client.guilds.cache.size)
const channels = (client.channels.cache.size)
const members = client.guilds.cache.reduce((acc, guild) => acc + guild.memberCount, 0);
const activities = [
{ type: 0, name: "ROBLOX" },
{ type: 0, name: "Grand Theft Auto 5" },
{ type: 0, name: "Fortnite" },
{ type: 0, name: "Farming Simulator 19" },
{ type: 2, name: `Spotify` },
{ type: 2, name: `AmNobCop` },
{ type: 2, name: `NotCaesahr` },
{ type: 3, name: `out for commands` },
{ type: 3, name: `YouTube` },
{ type: 3, name: `${servers} servers` },
{ type: 3, name: `${channels} channels` },
{ type: 3, name: `${members} members` }
];

const status = activities[Math.floor(Math.random() * activities.length)];
client.user.setActivity({ type: status.type, name: status.name });
}, 10000);
r u sayin like this?
probablyraging
Yes that would work, but that is also API spam
Baconburger998
Ye thats why i was wondering if there is a better way that wouldnt spam the api
probablyraging
Change the interval to be longer than 10s
Baconburger998
Ok
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
probablyraging
Like 30 mins
Baconburger998
mhm
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
probablyraging
That wouldn't work, timeouts only run once
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View