Reputation: 950
@client.event
async def on_member_join(member):
print(member)
role = discord.utils.get(member.guild.roles, name="☾│Unregister Of Hyperion")
await member.add_roles(role)
This is my code, it should print the users nick when it joins, but it doesn't. The bot gives the role but it doesnt print. The same code works on my other bot. I have no idea why it doesnt work in this.
Upvotes: 1
Views: 132
Reputation: 4743
In the new version of discord.py(1.5.x), there're some updates about Intents
. Intents are similar to permissions, you have to define Intents to get channels, members and some events etc. You have to define it before defining the client = discord.Bot(prefix='')
.
import discord
intents = discord.Intent().all()
client = discord.Bot(prefix='', intents=intents)
@client.event
async def on_member_join(member):
print(member)
role = discord.utils.get(member.guild.roles, name="☾│Unregister Of Hyperion")
await member.add_roles(role)
If you want to get more information about Intents, you can look at the API References.
Upvotes: 0