C
C
Cyril Septimoor2020-12-05 16:37:40
Python
Cyril Septimoor, 2020-12-05 16:37:40

Discord bot does not want to delete the channel after creation, what should I do?

I can’t understand what the problem is, I tried to give the bot an opportunity to make a personal private channel if someone enters a certain creation channel. Everything would be fine, it creates a channel and everything is fine, but it gives an error. I forgot to clarify, when exiting the channel should be deleted (the one that was created in the process)

if after.channel.id == 784772588152553492:
AttributeError: 'NoneType' object has no attribute 'id'

Create - creates, does not want to delete.
Here is the code:

@client.event
@commands.has_permissions( kick_members = True )
async def on_voice_state_update(member, before, after):
    if after.channel.id == 784772588152553492:
        for guild in client.guilds:
            category = discord.utils.get(guild.categories, id=734934134618718330)
            channel2 = await guild.create_voice_channel(name = f' {member.display_name}',category = category)
            await channel2.set_permissions(member, connect=True, mute_members=True, move_members=True, manage_channels=True)
            await member.move_to(channel2)
            def check(x,y,z):
                return len(channel2.member) == 0
            await client.wait_for('voice_state_update', check=check)
            await channel2.delete()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Amoralny, 2020-12-05
@poha_sep

I have described here a way to not wait for anything.
Why doesn't the bot delete the private channel after it's created?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question