generated from Baipyrus/DiscordJS-Template
bugfix: only delete registered custom channels
This commit is contained in:
parent
e69806c132
commit
cb1662cefb
@ -63,6 +63,15 @@ const leftVoiceChat = async (state) => {
|
||||
const members = Array.from(channel.members);
|
||||
if (members.length > 0) return;
|
||||
|
||||
// Find channel by id, return if not registered as custom
|
||||
const custom = await VoiceChannel.findOne({
|
||||
where: {
|
||||
id: channel.id,
|
||||
create: false
|
||||
}
|
||||
});
|
||||
if (custom === null) return;
|
||||
|
||||
// Delete channel from guild
|
||||
await channel.guild.channels.delete(channel.id);
|
||||
console.info(`[INFO] Custom VC with ID '${channel.id}' was empty and got deleted.`);
|
||||
@ -73,6 +82,18 @@ export async function execute(oldState, newState) {
|
||||
if (!newState.channel)
|
||||
return await leftVoiceChat(oldState);
|
||||
|
||||
console.log(
|
||||
Array.from(
|
||||
newState
|
||||
.channel
|
||||
.permissionOverwrites
|
||||
.cache
|
||||
.values()
|
||||
).forEach(overwrite =>
|
||||
console.log(overwrite.allow.toArray())
|
||||
)
|
||||
);
|
||||
|
||||
// Find channel by id, return if not registered for customs
|
||||
const createCh = await VoiceChannel.findOne({
|
||||
where: {
|
||||
|
Loading…
Reference in New Issue
Block a user