Switch to Python #2

Merged
bene merged 4 commits from python into main 2024-05-25 17:04:36 +00:00
Showing only changes of commit f44c8a778f - Show all commits

6
bot.py
View File

@@ -24,12 +24,10 @@ async def on_voice_state_update(member, before, after):
reason='Created by JoinToCreate bot' reason='Created by JoinToCreate bot'
) )
await member.move_to(new_channel) await member.move_to(new_channel)
# Mark the channel as created by the bot by adding a custom attribute
new_channel.created_by_bot = True
if before.channel and len(before.channel.members) == 0 and before.channel.id != join_to_create_channel_id: if before.channel and len(before.channel.members) == 0 and before.channel.id != join_to_create_channel_id:
# Check if the channel was created by the bot before deleting it # Check if the channel was created by the bot by checking its name
if hasattr(before.channel, 'created_by_bot') and before.channel.created_by_bot: if before.channel.name.startswith('🔊'):
await before.channel.delete(reason='No members left in the bot-created channel') await before.channel.delete(reason='No members left in the bot-created channel')
bot.run(token) bot.run(token)