A
A
Angeloffy2021-11-12 12:42:27
Python
Angeloffy, 2021-11-12 12:42:27

The category name is not updated, how to fix it?

Good day, I have a piece of code:

@client.event
async def on_voice_state_update(member, before, after):
        channel = client.get_channel(908270672290132002)
        members = channel.members
        memids = []
        category = client.get_channel(908270672290132000)
        for member in members:
            memids.append(member.id)
            count = len(memids)
            await category.edit(name = str(count))


The count variable correctly returns the number of members in the channel, but does not update per cd in await category.edit(name = str(count))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2021-11-12
@Angeloffy

And why do you update constantly for each user? Someone entered / left, took the number of participants, entered it in the name of the channel

@client.event
async def on_voice_state_update(member, before, after):
    members_count = len(client.get_channel(908270672290132002).members)
    client.get_channel(908270672290132000).edit(name = str(members_count))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question