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

Commit

Permalink
Implement text channel permission setting
Browse files Browse the repository at this point in the history
  • Loading branch information
kyogoi committed Oct 6, 2019
1 parent 4f911d5 commit 49b6e73
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,23 @@

// 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) {
const voiceChannel = bot.channels.get(oldMember.voiceChannelID);
const textChannel = bot.channels.get(channels.find((v) => v.voice_id == oldMember.voiceChannelID).text_id);

if (!voiceChannel.members.length) {
db.run('UPDATE channels SET set_to_purge = 1 WHERE voice_id = ?', [oldMember.voiceChannelID]);
}

textChannel.permissionOverwrites.find((v) => v.id == oldMember.id).delete();
}

// Dealing with a linked channel
if (channels.some((v) => v.voice_id == newMember.voiceChannelID)) {
const textChannel = bot.channels.get(channels.find((v) => v.voice_id == newMember.voiceChannelID).text_id);

db.run('UPDATE channels SET set_to_purge = 0 WHERE voice_id = ?', [newMember.voiceChannelID]);

textChannel.overwritePermissions(newMember, { "VIEW_CHANNEL": true });
}

});
Expand Down

0 comments on commit 49b6e73

Please sign in to comment.