Skip to content

Commit 5b10798

Browse files
committed
fixes
1 parent e4f1528 commit 5b10798

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

src/commands/modules/bind.js

+22-3
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,13 @@ class Bind extends Command {
2020
const channelNames = (server.bind || []).forEach((id) => {
2121
const channel = server.guild.channels.cache.get(id);
2222
const user = server.guild.members.cache.get(id);
23+
const role = server.guild.roles.cache.get(id);
2324
if (user) {
2425
obj[user.displayName] = id;
2526
} else if (channel && channel.name) {
2627
obj[channel.name] = id;
28+
} else if (role) {
29+
obj[role.name] = id;
2730
} else {
2831
obj[id] = 'Channel Not Found';
2932
}
@@ -51,6 +54,7 @@ class Bind extends Command {
5154
[command + ' voice_channel_id']: server.lang('bindusage.channel'),
5255
[command + ' #text_channel']: server.lang('bindusage.text_channel'),
5356
[command + ' @username']: server.lang('bindusage.username'),
57+
[command + ' @role']: server.lang('bindusage.role'),
5458
[command + ' permit']: server.lang('bindusage.permit'),
5559
[command + ' unpermit']: server.lang('bindusage.unpermit'),
5660
},
@@ -99,11 +103,18 @@ class Bind extends Command {
99103
});
100104
}
101105

106+
if (mentions.roles.size) {
107+
mentions.roles.forEach((role) => {
108+
if (!server.bind.includes(role.id)) server.bind.push(role.id);
109+
});
110+
}
111+
102112
for (const id of input.args) {
103113
if (id.length > 15 && /^\d+$/.test(id.trim())) {
104114
const user = server.guild.members.cache.get(id);
105115
const channel = server.guild.channels.cache.get(id);
106-
if (user || (channel && channel.type != 'voice')) continue;
116+
const role = server.guild.roles.cache.get(id);
117+
if (user || (channel && channel.type != 'voice') || role) continue;
107118

108119
if (!server.bind.includes(id)) server.bind.push(id);
109120
}
@@ -125,7 +136,13 @@ class Bind extends Command {
125136
async onUserJoinedChannel({ channelState, member, server }) {
126137
// throw out these states
127138
if (!member.voice.channelID) return;
128-
if (!server.bind || !server.bind.length || !server.bind.includes(channelState.channelID)) return;
139+
if (!server.bind || !server.bind.length) return;
140+
141+
if (
142+
!server.bind.includes(channelState.channelID) &&
143+
!server.bind.some((id) => member.roles.cache.has(id))
144+
)
145+
return;
129146

130147
if (!server.isBound()) {
131148
server.setMaster(member);
@@ -148,7 +165,9 @@ class Bind extends Command {
148165
//not a channel
149166
(!server.bind.includes(channel.id) &&
150167
//not a user
151-
!server.bind.includes(member.id))
168+
!server.bind.includes(member.id) &&
169+
// not a role
170+
!server.bind.some((id) => mentions.roles.has(id)))
152171
) {
153172
return;
154173
}

0 commit comments

Comments
 (0)