Skip to content

Commit bb6b5b2

Browse files
authored
Merge pull request #132 from allthingslinux/tempvc-cleanup
[Events] cleanup unused tempvcs lost during bot restarts
2 parents d83b516 + af93e0d commit bb6b5b2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tux/cogs/utility/temp_vc.py

+14
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,20 @@ async def on_voice_state_update(
4343
f"Deleted temporary channel {before.channel.name} as it has no members."
4444
)
4545

46+
# search all lost temporary channels and delete them
47+
for channel in category.voice_channels:
48+
# checks if the channel is a temporary channel
49+
if (
50+
not channel.name.startswith(self.base_vc_name)
51+
or len(channel.members) != 0
52+
or channel.id == int(CONST.TEMPVC_CHANNEL_ID or "0")
53+
):
54+
continue
55+
56+
if len(channel.members) == 0:
57+
await channel.delete()
58+
logger.info(f"Deleted temporary channel {channel.name} as it has no members.")
59+
4660

4761
async def setup(bot: commands.Bot) -> None:
4862
await bot.add_cog(TempVc(bot))

0 commit comments

Comments
 (0)