Discord I';我试图让我的机器人给使用该命令的人一个角色,但它说;属性错误:';元组';对象没有属性';id'&引用;

Discord I';我试图让我的机器人给使用该命令的人一个角色,但它说;属性错误:';元组';对象没有属性';id'&引用;,discord,discord.py,Discord,Discord.py,我是一个完全的初学者,所以有人能告诉我这里有什么问题,以及如何解决它吗?多谢各位 from discord.ext import commands from discord.utils import get @client.command() async def reserve(message, *, stand): channel = message.channel, author = message.author, guild = mess

我是一个完全的初学者,所以有人能告诉我这里有什么问题,以及如何解决它吗?多谢各位

from discord.ext import commands
from discord.utils import get


@client.command()
async def reserve(message, *, stand):
        channel = message.channel,
        author = message.author,
        guild = message.guild,
        the_world = get(message.guild.roles,name="The World"),
        if stand == 'The World':
            await message.author.add_roles(the_world)


The error:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'tuple' object has no attribute 'id'

假设在其他bot运行时,您提供的代码会导致此错误,因为您使用的是
get(ctx.guild.roles,name=“the World”)
,请确保在参数中使用
discord.utils

discord.utils.get(ctx.guild.roles,name=“The World”)

此外,我还修改了一些代码,作为命令,您不需要传递
消息
作为参数,使用
ctx及其属性

@client.command()
异步def储备(ctx,*,支架):
如果立场==‘世界’:
the_world=discord.utils.get(ctx.guild.roles,name=“the world”),
等待ctx.author.add_角色(_世界)

确保问题标题描述了实际问题。不要把
我是一个完全的初学者,我不明白这里出了什么问题。这对其他任何人都没有用。我尝试了你所说的,但仍然会出现相同的错误“AttributeError:“tuple”对象没有属性“id”