R
R
ratratrat2020-08-09 09:37:13
Python
ratratrat, 2020-08-09 09:37:13

Discord.py, how to auto-issue roles?

Good morning everyone! I'm just getting acquainted with discord.py and I don't know how to make the bot automatically issue a role when someone enters my server. Thanks in advance!
If there is such an opportunity, then it is desirable that the execution be from
@Bot.event

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Nevzorov, 2020-08-09
@rattratrat

> on_member_join(member)<

@Bot.event
async def on_member_join(member):
    if role := member.guild.get_role(418187634689139935):
        await member.add_roles(role)

R
Rostislavcheg, 2020-08-09
@Rostislavcheg

@Bot.event #
async EVENT def on_member_join(memner): # SERVER LOGIN EVENT
role = discord.utils.get(member.guild.roles, name='Role name') # THE ROLE I'M GIVING
await member.add_roles( role) # ADD ROLE

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question