aboutsummaryrefslogtreecommitdiff
path: root/174bg/discord-bot/source/utilities/notifyRoleByName.js
diff options
context:
space:
mode:
authorAlex Pooley (@zuedev) <zuedev@gmail.com>2026-07-22 15:32:57 +0100
committerAlex Pooley (@zuedev) <zuedev@gmail.com>2026-07-22 15:32:57 +0100
commit72487019b3f255cece40a8073bbad8bc9968a3b7 (patch)
treeb6590e63039cdc8b1820bd345cdfe83f28ff839b /174bg/discord-bot/source/utilities/notifyRoleByName.js
parentda0509c91376f56f133872eddd2e4282d76f215e (diff)
downloadunnamed-group-72487019b3f255cece40a8073bbad8bc9968a3b7.tar
unnamed-group-72487019b3f255cece40a8073bbad8bc9968a3b7.tar.gz
unnamed-group-72487019b3f255cece40a8073bbad8bc9968a3b7.tar.bz2
unnamed-group-72487019b3f255cece40a8073bbad8bc9968a3b7.tar.xz
unnamed-group-72487019b3f255cece40a8073bbad8bc9968a3b7.zip
major code refactor, add uex lookup
Diffstat (limited to '174bg/discord-bot/source/utilities/notifyRoleByName.js')
-rw-r--r--174bg/discord-bot/source/utilities/notifyRoleByName.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/174bg/discord-bot/source/utilities/notifyRoleByName.js b/174bg/discord-bot/source/utilities/notifyRoleByName.js
new file mode 100644
index 0000000..1b2b82a
--- /dev/null
+++ b/174bg/discord-bot/source/utilities/notifyRoleByName.js
@@ -0,0 +1,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);
+ }
+};