此命令应该将角色应用于提到的用户。我的代码:
@commands.command(name="manualverify")
async def manualverify(self, ctx, membertag:discord.User, ethaddy):
member = membertag
var6 = discord.utils.get(member.guild_roles, name = str("?SAINT_LESS"))
await member.add_roles(var6)
这是完整的回溯:
Traceback (most recent call last):
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "C:\Users\Administrator\Desktop\xcopy bot\cogs\main.py", line 447, in manualverify
var6 = discord.utils.get(member.guild.roles, name = str("?SAINT_LESS"))
AttributeError: 'User' object has no attribute 'guild'
有人对我如何解决这个问题有任何建议吗?
答案 0 :(得分:0)
正如 BubbyBob 的评论中所说,以下代码将起作用。会员有公会属性,而用户没有。这可以看到here in the Discord.py documentation.
@commands.command(name="manualverify")
async def manualverify(self, ctx, membertag:discord.Member, ethaddy):
member = membertag
var6 = discord.utils.get(member.guild_roles, name = str("?SAINT_LESS"))
await member.add_roles(var6)