How to find a role in a differnt guild discord.ks code example

Example 1: discord.js find role by name

let role = message.guild.roles.cache.find(role => role.name === "Rolename");

Example 2: discord.js get all members with role

//outputs the IDs of all members with the specified role as an array

// === discord.js v11 ===
message.guild.roles.get('ROLE-ID').members.map(m=>m.user.id);

// === discord.js v12 ===
message.guild.roles.cache.get('ROLE-ID').members.map(m=>m.user.id);