Reputation: 45
I am writing a bot for discord in Python. I want that when someone logged in to the server, he was given a certain role
import discord
from discord.ext import commands
from discord.ext.commands import bot
bot = commands.Bot(command_prefix='!')
from discord.utils import get
@bot.event
async def on_member_join(member):
role = get(member.roles, name="Игроки")
await bot.add_roles(member, role)
When I start and someone enters the server, I get the following error: AttributeError: 'Bot' object has no attribute 'add_roles'
Upvotes: 3
Views: 11653
Reputation: 60984
Make sure you're using the latest version of the documentation. You should be getting the role from the guild and using Member.add_roles
@bot.event
async def on_member_join(member):
role = get(member.guild.roles, name="Игроки")
await member.add_roles(role)
Upvotes: 5