Skip to content
Advertisement

How I can get channel members (Discord.py)

I need to get Only users of my channel, but I have not found a function that returns the desired result. There is a function to get all users of the bot: get_all_members(), but she’s not doing exactly what I need. I want get user nicknames. Help me find a solution to my problem.

Advertisement

Answer

Hm… I had this issue in a bot I was making a while ago…

Assuming you want people in the voice channel you are currently in, here is the code to get the users for the voice channel…

def foo(ctx):
    voice_channel_list = ctx.guild.voice_channels
    for voice_channels in voice_channel_list:
        for member in voice_channels.members:

This will give you all the member objects of the voice channel ctx.author is currently in. I hope this is what you are looking for. If not, let me know and I’ll change my answer (if I know the answer).

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement