Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

discord.py bot can't see members

I'm trying to do a discord bot that creates a category and sets permissions to roles and users, taking the users id as arguments:

for x in range(2, len(args)):
member= client.get_user(int(args[x]))
await message.guild.categories[-1].set_permissions(member, send_messages = True)

where args is the string array that contains the command, the name of the category, and the user IDs. the usage should be:

!create category-name 0000000 1111111

I have some problems with that, because is like the bot can't see the members of the server, and the only user he can add is me, the owner of the server if specified in the first argument (000000 in my example). If i put someone else's ID, the bot is not gonna add permissions for that user in the category. I figured out that maybe the bot can't see other users, in fact if i put the line:

print(message.guild.members)

it is gonna print only the bot as member,

prints this: [<Member id=762749337700007946 name='RoomBzot' discriminator='1334' bot=True nick=None guild=>]

I have no idea of the reason why it counts the members but can't see the other users, what can I do?

like image 994
PeppeBz Avatar asked Jan 22 '26 06:01

PeppeBz


1 Answers

Since the answer linked by derw is no longer available;

As OP indicates, I managed to solve this by instantiating the discord bot client as follows:

intents = discord.Intents.default()
intents.members = True
client = discord.Client(intents=intents)

In addition I had to enable the "SERVER MEMBERS INTENT" Privileged Gateway Intent under my bot settings in the Discord developer portal:

Enabling Server Members Intent

like image 189
Jonathan W Avatar answered Jan 24 '26 18:01

Jonathan W



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!