#database python

1 messages · Page 1 of 1 (latest)

north terrace
#
@discord.default_permissions(manage_roles=True)  
async def setrole(ctx, role: discord.Role):
  guild = {"_id": ctx.guild.id, "role_id": role.id}
  result = await role_db.find_one(guild)
  print(result)
  if result:
      res = await role_db.replace_one(
    {"_id": guild, "role_id": role.id},
    {"_id": guild, "role_id": role.id}
)
    
      print(res)

      print(result)
      # insted of sending a message why dont you update the data a new role 
      await ctx.respond(f"Updated the role to {role.mention}")
  else:
      await role_db.insert_one(guild)
      await ctx.respond("Role Added to db", ephemeral=True)```
trim mountain
#

Read the error

last iron
#

^

#

it literally tells you whats wrong

north terrace
#

if its given error

last iron
#

#how-to-get-help / #help-rules

Try using google first and get a bit more familar with python / the database framework you use