So I'm attempting to write a raiding bot for my raiding discord using the discord.py library in python. This scripts is supposed to be forming a list of members in the voice channel for raiding. For some reason, this script is not working. Whenever memids is printed, it just prints an empty list.
If anyone is familiar with discord.py and could tell me why this isn't working, please do. It's really troubling me and I have tried everything in my knowledge to fix it.
#find raiding
voice_channel = discord.utils.get(ctx.message.server.channels, id = '440014722587426816')
#finds the members
members = voice_channel.voice_members
memids = []
for member in members:
memids.append(member.id)
print(memids)
There isn't much to go on from your question. I believe your problem is that the id
that you provided to utils.get(...)
isn't the correct id of the voice channel. This is probably the reason to why you're always getting an empty list.
A list of
Members
that are currently inside this voice channel. Iftype
is notChannelType.voice
then this is always an empty array.
If you're not fully sure about the voice channel's actual id
, I suggest you search by the name and type (discord.ChannelType.voice
):
voice_channel = discord.utils.get(ctx.message.server.channels, name="channelname", type=discord.ChannelType.voice)