[英]Discord.py Rewrite. How to create a command to add roles?
我正在尝试创建一个机器人,允许用户通过键入 .lfg(前缀 = .)将自己添加到角色(寻找组)。 我已经尝试查看 API 参考,但仍然不明白如何使用discord.Member.add_roles
到目前为止,这是我的代码:
@client.command(pass_context=True)
async def lfg(ctx):
member = ctx.message.author
test = discord.utils.get(member.guild.roles, name="Looking for group")
print(test)
await discord.Member.add_roles(test,reason=None,atomic=True)
await ctx.send("Role added")
它应该是 member.add_roles() 因为您已经将 ctx.author 定义为 member 并且不需要 pass_context
@client.command()
async def lfg(ctx):
member = ctx.message.author
test = discord.utils.get(member.guild.roles, name="Looking for group")
print(test)
await member.add_roles(test,reason=None,atomic=True)
await ctx.send("Role added")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.