-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathno-ping.js
34 lines (30 loc) · 1.03 KB
/
no-ping.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const STAFF_ROLES = process.env.DISCORD_STAFF_ROLES.split(',');
module.exports = client => {
client.on('message', async msg => {
// Ignore DMs, messages that don't mention anyone, messages that are a reply, and messages from bots.
if (msg.channel.type !== 'text') return;
if (msg.mentions.members.size === 0) return;
if (msg.reference !== null) return;
if (msg.member.user.bot) return;
const senderIsStaff = msg.member.roles.cache.some(
role => STAFF_ROLES.indexOf(role.name) !== -1
);
if (senderIsStaff) {
return;
}
const mentionsStaff = msg.mentions.members.some(member => {
// If the message mentions any members that satisfy the following:
return member.roles.cache.some(
role => STAFF_ROLES.indexOf(role.name) !== -1
);
});
if (mentionsStaff) {
// Tell them off:
await msg.channel.send(
`Hey ${
msg.member.nickname ?? msg.author.username
}! Please don't tag helpful/staff members directly.`
);
}
});
};