I maked an auto roles giving system with on_member_join
event, it has worked until now, now it’s not sending messages to members, and not giving roles. Please help:
@bot.event async def on_member_join(member): Role1 = discord.utils.get(member.guild.roles, id = 723244173779533925) await member.add_roles(Role1) Role2 = discord.utils.get(member.guild.roles, id = 723244271628582962) await member.add_roles(Role2) Role3 = discord.utils.get(member.guild.roles, id = 723563998393663499) await member.add_roles(Role3) await member.send('Hi, welcome to my server! In 30 seconds i will give you verified role, please **read rules** in that time.') await asyncio.sleep(30) verifiedRole = discord.utils.get(member.guild.roles, id = 788393533874765855) await member.add_roles(verifiedRole) await member.send('I given you the verified role, and you have access to the rest of the guild.')
Advertisement
Answer
It sounds like you need intents.
You’ll need to add this code above your definition of bot
:
intents = discord.Intents.default() intents.members = True
Now, add the intents=intents
parameter to your bot initialization underneath the intents bit:
intents = discord.Intents.default() intents.members = True # If you have commands.Bot, add `intents = intents` in the parentheses: bot = commands.Bot(your_options_here,intents = intents) # If you have discord.Client(), add `intents = intents` into the parentheses: bot = discord.Client(intents = intents)
Make sure you enable the members intent in the developer portal. You can read up on intents more here.