blob: 1b2b82aad5a2148ccdf51c6fded39c7f1b85f69e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
export default async (guild, roleName, message) => {
// get the role by name
const role = guild.roles.cache.find(
(role) => role.name.toLowerCase() === roleName.toLowerCase(),
);
if (!role) {
console.error(`Role "${roleName}" not found.`);
return;
}
// get all members with the role
const membersWithRole = role.members;
// send a DM to each member with the role
for (const member of membersWithRole.values()) {
await member.send(message);
}
};
|