-
Notifications
You must be signed in to change notification settings - Fork 0
/
jail.js
43 lines (40 loc) · 1.23 KB
/
jail.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
35
36
37
38
39
40
41
42
43
// const JAIL_ROLE_ID = "441698026906451988"; // test role
const JAIL_ROLE_ID = "419145027307175937";
function jail(message) {
const jail_role = message.guild.roles.get(JAIL_ROLE_ID);
if (message.mentions.members.size < 1) {
// no user specified, error
return -1;
}
const target = message.mentions.members.first();
if (target.roles.has(jail_role.id)) {
// user already has role, error
return 1;
} else if (target.id == message.member.id) {
// user trying to set own role
return 2;
} else {
target.addRole(jail_role).catch(console.log);
return 0;
}
}
function bail(message) {
const jail_role = message.guild.roles.get(JAIL_ROLE_ID);
if (message.mentions.members.size < 1) {
// no user specified, error
return -1;
}
const target = message.mentions.members.first();
if (!target.roles.has(jail_role.id)) {
// user doesn't have role, error
return 1;
} else if (target.id == message.member.id) {
// user trying to set own role
return 2;
} else {
target.removeRole(jail_role).catch(console.log);
return 0;
}
}
module.exports.jail = jail;
module.exports.bail = bail;