Skip to content
This repository has been archived by the owner on Nov 19, 2019. It is now read-only.

Commit

Permalink
Add same voice channel check
Browse files Browse the repository at this point in the history
  • Loading branch information
kyogoi committed Oct 6, 2019
1 parent 066f768 commit 4f911d5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,19 @@
}

bot.on('voiceStateUpdate', async (oldMember, newMember) => {
if (oldMember.voiceChannelID === newMember.voiceChannelID) return;

const channels = await db.all('SELECT voice_id, text_id FROM channels');

// Dealing with a purge channel
// Dealing with a linked channel
if (channels.some((v) => v.voice_id == oldMember.voiceChannelID)) {
const channel = bot.channels.get(oldMember.voiceChannelID);
if (!channel.members.length) {
db.run('UPDATE channels SET set_to_purge = 1 WHERE voice_id = ?', [oldMember.voiceChannelID]);
}
}

// Dealing with a purge channel
// Dealing with a linked channel
if (channels.some((v) => v.voice_id == newMember.voiceChannelID)) {
db.run('UPDATE channels SET set_to_purge = 0 WHERE voice_id = ?', [newMember.voiceChannelID]);
}
Expand Down

0 comments on commit 4f911d5

Please sign in to comment.