Im pretty new to discord.py and would like to get the ids of all the people in the discord server that the bot is used in.
Thanks, Aarav
Im pretty new to discord.py and would like to get the ids of all the people in the discord server that the bot is used in.
Thanks, Aarav
First use should get guild
object from ctx.guild
in command event, message.guild
in on_message event, etc. Then choose the sample below.
The sample to go through all members and do some stuff
for member in guild.members:
id = member.id
# Do stuff here
The sample to get a list of all members ids
ids = [member.id for member in guild.members]
The sample to get an itterator of all members ids
def get_all_members_ids(guild):
for member in guild.members:
yield member.id
# And then use it like this
for id in get_all_members_ids(guild):
# Do stuff here