Home > database >  AttributeError: 'Interaction' object has no attribute 'author'
AttributeError: 'Interaction' object has no attribute 'author'

Time:01-31

my nextcord bot was supposed to get the author id but instead gives out an error

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

Here's the code


@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")

CodePudding user response:

Use message.user, also that would be returning an interaction, so it would be more standardized to use "interaction" instead of "message" as the var name, just to make your question more clear for the future.

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