小编Dex*_*ter的帖子

AttributeError:“Bot”对象没有属性“add_roles”

我正在用 Python 编写一个用于discord 的机器人。我希望当有人登录到服务器时,他被赋予一定的角色

\n\n
import discord\nfrom discord.ext import commands\nfrom discord.ext.commands import bot\nbot = commands.Bot(command_prefix=\'!\')\nfrom discord.utils import get\n\n@bot.event\nasync def on_member_join(member):\n    role = get(member.roles, name="\xd0\x98\xd0\xb3\xd1\x80\xd0\xbe\xd0\xba\xd0\xb8")\n    await bot.add_roles(member, role)\n
Run Code Online (Sandbox Code Playgroud)\n\n

当我启动并且有人进入服务器时,出现以下错误:\nAttributeError: \'Bot\' object has no attribute \'add_roles\'

\n

python discord discord.py

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

discord ×1

discord.py ×1

python ×1