My warn command is not working discord.py

(Replit.com) I tried to use the warn command but every time i try, there is a error: TypeError: ‘Command’ object is not subscriptable

with open('warns.json', encoding='utf-8') as f:
    try:
        report = json.load(f)
    except ValueError:
        report = {}
        report['users'] = []
@client.command(pass_context=True)
@commands.has_permissions(manage_roles=True, ban_members=True)
async def warn(ctx, user: discord.User, *reason: str):
  if not reason:
    await ctx.send("Please provide a reason")
    return
    author = ctx.author
    reason = ' '.join(reason)
    embed = discord.Embed(title=f'{author.name} warned {user.name} for')
  for current_user in report['users']:
    if current_user['name'] == user.name:
      current_user['reasons'].append(reason)
      break
  else:
      report['users'].append({
            'name': user.name,
            'reasons': [
                reason,
            ]
        })
  with open('warns.json', 'w+') as f:
    json.dump(report, f)
  await ctx.send(embed=embed)

The error message I get is:

File "main.py", line 411, in warn 
    for current_user in report['users']: 
TypeError: 'Command' object is not subscriptable 

Answer

The problem is, that aside the report dictionary, you also have a command called report, so to fix this error, simply rename either the global variable or the command. Also instead of saving the users by name, you should save them by their id (current_user.id instead of current_user.name ), because Nitro users can change their discriminator to avoid any warns.