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 User3y ago
Message Not Public
Sign In & Join Server To View
JollyJohn
JollyJohnOP3y ago
now how would i make it so it would set the status to watching if the thing was ${members} anyone wanna help
MrMythical
MrMythical3y ago
5 seconds is way too short of an interval
JollyJohn
JollyJohnOP3y ago
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
JollyJohn
JollyJohnOP3y ago
so like the const inside the interval?
probablyraging
Sure, that would work
JollyJohn
JollyJohnOP3y ago
is there a better way?
probablyraging
What do you mean by "better"?
JollyJohn
JollyJohnOP3y ago
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
JollyJohn
JollyJohnOP3y ago
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
JollyJohn
JollyJohnOP3y ago
Ok
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
probablyraging
Like 30 mins
JollyJohn
JollyJohnOP3y ago
mhm
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
probablyraging
That wouldn't work, timeouts only run once
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server