Skip to content
Advertisement

Role auto-assignment bot

The bot does not issue a role when the user connects (there are no errors either)

code:

import discord
from discord.ext import commands
from discord.utils import get

TOKEN = ''

client = commands.Bot(command_prefix='>')

@client.event
async def on_member_join(member):
    role = discord.utils.get(member.guild.roles, id=int("680703508940455977"))
    await member.add_roles(role)
    
client.run(TOKEN)

Advertisement

Answer

Starting from Discord 1.5, you now need to pass in Intents. Everything is explained in the API docs (link). In your case you need the members intent. Remember to also enable it on your bot’s application page (as is explained in the link).

Without the members intent, on_member_join() will not activate.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement