Loops through retrieving all servers your bot is on and adds them to a big array :D
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
var lastID = null;
var allGuilds = []; //create empty array that will become one big array with many 100s of servers in it
do {
let listGuilds = await lib.discord.guilds['@0.2.4'].list({
after: lastID, //useing lastID allows us to grabe the *next* 100 servers
limit: 100, //max 100
});
allGuilds = allGuilds.concat(listGuilds); //add listGuilds to allGuilds
try {
lastID = listGuilds[99].id; //last Id is the 100th id in listGuilds
} catch (e) {
lastID = undefined; // if there was no 100th id in listGuilds meaning that would be the last one required, set to undefined
}
} while (lastID != undefined); //continute looping untill lastID is undefined
console.log(allGuilds.length);
//post number of guilds to status
await lib.discord.users['@0.2.0'].me.status.update({
activity_name: `users on ${allGuilds.length} servers!`,
activity_type: 'LISTENING',
status: 'ONLINE',
});