B
B
Beeskee42020-10-23 14:58:02
Python
Beeskee4, 2020-10-23 14:58:02

How to list the members of a Discord voice channel?

I still learned how to return the participants of the voice channel, but the trouble is: as I connect to the voice channel, the participants are supplemented in Embed, but instead of this, when a new participant is connected, the name of the participant who connected before it changes to the nickname of the participant, only that connected. Help! There is @bot.event in the code, I just didn't capture it for copying.

async def on_voice_state_update( member, before, after ):
    members_list = []
    if after.channel.name == channel.name:
      members_list.append( member.name )
      members = ', '.join( members_list )
      print( members )

      new_emb = discord.Embed( colour = discord.Color.red() )
      new_emb.set_footer( text = 'Virtuoso Bot by Beeskee' )
      new_emb.set_author( name = f'{author_name} ищет себе команду для игры в LoL!', icon_url = author_avatar )
      new_emb.add_field( name = members , value = 'ᅠ' )
      new_emb.add_field( name = f'Примечание:', value = '123', inline = False )
      new_emb.add_field( name = f'Имя призывателя:', value = f'`11`' )
      new_emb.add_field( name = f'Сервер:', value = f'`11`' )
      new_emb.add_field( name = 'Присоединиться:', value = f'[Нажми, чтобы присоединиться]({invite})', inline = False )
      new_emb.set_thumbnail( url = 'https://media4.giphy.com/media/uvl8IUWxxMk1KCKGJ0/giphy.gif' )
      await embed.edit( embed = new_emb )

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Nevzorov, 2020-10-23
@Beeskee4

members_list = []is built each time the function is executed in your case.
In this case, you need members_listto declare outside the function, but in this context it will be much easier to simply pull the participants of the voice channel from the channel itself:

members = ", ".join(m.name for m in after.channel.members)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question