@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)```
#database python
1 messages · Page 1 of 1 (latest)