Outputs an array of user ID's which have a specified role
// authenticates you with the API standard library
// type `await lib.` to display API autocomplete
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let users = await lib.discord.guilds['@0.1.3'].members.list({
guild_id: `${context.params.event.guild_id}`,
limit: 100,
});
let args = context.params.event.data.options[0].value.replace(/\D/g, ''); //removing non numeric parts from parameter
var result = new Array();
for (let i = 0; i < users.length; i++)
{
if (users[i].roles.includes(args))
{
result.push(`<@${users[i].user.id}>`);
}
}
console.log(`Mentioned Role: ${args}`);
console.log(result);
await lib.discord.channels['@0.0.6'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `Users: \n${result}`
});