Added method to clear the roles from the database when the user has been unmuted

pull/8/head
sgoudham 4 years ago
parent d64db3eaa9
commit a920f511f5

@ -255,7 +255,26 @@ async def storeRoles(target, ctx, member):
# Execute the query # Execute the query
await cur.execute(update_query, update_vals) await cur.execute(update_query, update_vals)
await conn.commit() await conn.commit()
print(cur.rowcount, f"Roles Added For User {member} in {ctx.guild.name}") print(cur.rowcount, f"{len(role_ids)} Roles Added For User {member} in {ctx.guild.name}")
async def clearRoles(ctx, member):
"""Clear the roles when the user has been unmuted"""
# Setup pool
pool = await connection(db.loop)
# Setup up pool connection and cursor
async with pool.acquire() as conn:
async with conn.cursor() as cur:
# Clear the existing roles of the user from the database
update_query = """UPDATE members SET roles = NULL WHERE guildID = (%s) AND discordID = (%s)"""
update_vals = ctx.guild.id, member.id
# Execute the query
await cur.execute(update_query, update_vals)
await conn.commit()
print(cur.rowcount, f"Roles Cleared For User {member} in {ctx.guild.name}")
# Run the async function to store everything in cache # Run the async function to store everything in cache

Loading…
Cancel
Save