Run the command !addrole @role and the role you pinged will get added to 1000 members of the guild. Change your timeout to 30.000 for better results.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
/*
WARNING THIS MIGHT GET YOU TIMED OUT BY AUTOCODE.
CHANGE THE TIMEOUT ON THE BOTTOM LEFT FROM 10.000
TO 30.000 SO YOU CAN ADD MORE ROLES. (if you have payed plan change the number to the one mentioned in your plan.)
*/
//getting the id of the role mentioned
let role = context.params.event.mention_roles[0]
//getting a list of 1000 users in the server
let members = await lib.discord.guilds['@0.2.4'].members.list({
guild_id: `${context.params.event.guild_id}`,
limit: 1000
});
//will run the code bellow x times based on how many users are in the guild
for (let i = 0; i < members.length; i++){
try {
//giving the role to the user
await lib.discord.guilds['@0.2.4'].members.roles.update({
role_id: `${role}`,
user_id: `${members[i].user.id}`,
guild_id: `${context.params.event.guild_id}`
});
} catch (e) {
//check logs on the right for errors
console.log(e);
}
}