Fixed bots being counted as users in voice channels
This commit is contained in:
parent
d42c67cde2
commit
c8d8973d7b
3 changed files with 5 additions and 5 deletions
|
@ -8,7 +8,7 @@ class ForceSkipCommand extends MusicCommand {
|
||||||
if (!this.message.channel.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
|
if (!this.message.channel.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
|
||||||
if (!this.message.member.permissions.has("manageChannels")) return "You need to have the `Manage Channels` permission to force skip!";
|
if (!this.message.member.permissions.has("manageChannels")) return "You need to have the `Manage Channels` permission to force skip!";
|
||||||
this.connection.player.stop(this.message.channel.guild.id);
|
this.connection.player.stop(this.message.channel.guild.id);
|
||||||
skipVotes.set(this.message.channel.guild.id, { count: 0, ids: [], max: Math.min(3, this.connection.voiceChannel.voiceMembers.size - 1) });
|
skipVotes.set(this.message.channel.guild.id, { count: 0, ids: [], max: Math.min(3, this.connection.voiceChannel.voiceMembers.filter((i) => i.id !== this.client.user.id && !i.bot).length) });
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ class SkipCommand extends MusicCommand {
|
||||||
if (!this.message.channel.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
|
if (!this.message.channel.guild.members.get(this.client.user.id).voiceState.channelID) return "I'm not in a voice channel!";
|
||||||
const player = this.connection;
|
const player = this.connection;
|
||||||
if (player.host !== this.message.author.id) {
|
if (player.host !== this.message.author.id) {
|
||||||
const votes = skipVotes.has(this.message.channel.guild.id) ? skipVotes.get(this.message.channel.guild.id) : { count: 0, ids: [], max: Math.min(3, player.voiceChannel.voiceMembers.size - 1) };
|
const votes = skipVotes.has(this.message.channel.guild.id) ? skipVotes.get(this.message.channel.guild.id) : { count: 0, ids: [], max: Math.min(3, player.voiceChannel.voiceMembers.filter((i) => i.id !== this.client.user.id && !i.bot).length) };
|
||||||
if (votes.ids.includes(this.message.author.id)) return "You've already voted to skip!";
|
if (votes.ids.includes(this.message.author.id)) return "You've already voted to skip!";
|
||||||
const newObject = {
|
const newObject = {
|
||||||
count: votes.count + 1,
|
count: votes.count + 1,
|
||||||
|
@ -17,7 +17,7 @@ class SkipCommand extends MusicCommand {
|
||||||
};
|
};
|
||||||
if (votes.count + 1 === votes.max) {
|
if (votes.count + 1 === votes.max) {
|
||||||
player.player.stop(this.message.channel.guild.id);
|
player.player.stop(this.message.channel.guild.id);
|
||||||
skipVotes.set(this.message.channel.guild.id, { count: 0, ids: [], max: Math.min(3, player.voiceChannel.voiceMembers.size - 1) });
|
skipVotes.set(this.message.channel.guild.id, { count: 0, ids: [], max: Math.min(3, player.voiceChannel.voiceMembers.filter((i) => i.id !== this.client.user.id && !i.bot).length) });
|
||||||
} else {
|
} else {
|
||||||
skipVotes.set(this.message.channel.guild.id, newObject);
|
skipVotes.set(this.message.channel.guild.id, newObject);
|
||||||
return `🔊 Voted to skip song (${votes.count + 1}/${votes.max} people have voted).`;
|
return `🔊 Voted to skip song (${votes.count + 1}/${votes.max} people have voted).`;
|
||||||
|
|
|
@ -6,7 +6,7 @@ export default async (client, cluster, worker, ipc, member, oldChannel) => {
|
||||||
if (!oldChannel) return;
|
if (!oldChannel) return;
|
||||||
const connection = players.get(oldChannel.guild.id);
|
const connection = players.get(oldChannel.guild.id);
|
||||||
if (connection && connection.type === "music" && oldChannel.id === connection.voiceChannel.id) {
|
if (connection && connection.type === "music" && oldChannel.id === connection.voiceChannel.id) {
|
||||||
if (oldChannel.voiceMembers.filter((i) => i.id !== client.user.id).length === 0) {
|
if (oldChannel.voiceMembers.filter((i) => i.id !== client.user.id && !i.bot).length === 0) {
|
||||||
connection.player.pause(true);
|
connection.player.pause(true);
|
||||||
const waitMessage = await client.createMessage(connection.originalChannel.id, "🔊 Waiting 10 seconds for someone to return...");
|
const waitMessage = await client.createMessage(connection.originalChannel.id, "🔊 Waiting 10 seconds for someone to return...");
|
||||||
const awaitRejoin = new AwaitRejoin(oldChannel, true);
|
const awaitRejoin = new AwaitRejoin(oldChannel, true);
|
||||||
|
@ -41,7 +41,7 @@ export default async (client, cluster, worker, ipc, member, oldChannel) => {
|
||||||
// no-op
|
// no-op
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const members = oldChannel.voiceMembers.filter((i) => i.id !== client.user.id);
|
const members = oldChannel.voiceMembers.filter((i) => i.id !== client.user.id && !i.bot);
|
||||||
if (members.length === 0) {
|
if (members.length === 0) {
|
||||||
try {
|
try {
|
||||||
if (waitMessage.channel.messages.get(waitMessage.id)) waitMessage.delete();
|
if (waitMessage.channel.messages.get(waitMessage.id)) waitMessage.delete();
|
||||||
|
|
Loading…
Reference in a new issue