AttributeError: 'Interaction' object has no attribute 'author'

AttributeError: 'Interaction' object has no attribute 'author'

我的 nextcord 机器人本应获得作者 ID,但却给出了错误

line 372, in creds
member_data = load_member_data(message.author.id)
AttributeError: 'Interaction' object has no attribute 'author

这是代码


@bot.slash_command(name='credits', description='Checks social credit score', guild_ids=guild_id)
async def creds(message):
    member_data = load_member_data(message.author.id)
    await message.channel.send(f"{message.author.mention} has "+ str(member_data.wallet) +" Social Credit Points")

使用message.user,这也会返回一个交互,所以使用“interaction”而不是“message”作为变量名会更标准化,只是为了让你的问题更清楚未来。

member_data = load_member_data(message.user.id)
await message.channel.send(f"{message.user.mention}...