bugfix: only delete registered custom channels

This commit is contained in:
Baipyrus 2024-02-08 20:13:12 +01:00
parent e69806c132
commit cb1662cefb

View File

@ -63,6 +63,15 @@ const leftVoiceChat = async (state) => {
const members = Array.from(channel.members); const members = Array.from(channel.members);
if (members.length > 0) return; 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 // Delete channel from guild
await channel.guild.channels.delete(channel.id); await channel.guild.channels.delete(channel.id);
console.info(`[INFO] Custom VC with ID '${channel.id}' was empty and got deleted.`); 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) if (!newState.channel)
return await leftVoiceChat(oldState); 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 // Find channel by id, return if not registered for customs
const createCh = await VoiceChannel.findOne({ const createCh = await VoiceChannel.findOne({
where: { where: {