Making it so that people can't marry people that are already married

pull/8/head
sgoudham 4 years ago
parent faa2eb06f1
commit 27b4ef613b

@ -23,24 +23,40 @@ class Relationship(commands.Cog):
# Use database connection # Use database connection
with db.connection() as conn: with db.connection() as conn:
# Get the author's row from the Members Table # Get the author's/members row from the Members Table
select_query = """SELECT * FROM members WHERE discordID = (?) and guildID = (?)""" select_query = """SELECT * FROM members WHERE discordID = (?) and guildID = (?)"""
val = ctx.author.id, guild.id, author_val = ctx.author.id, guild.id,
cursor = conn.cursor() member_val = member.id, guild.id,
# Execute the SQL Query # Define two cursors
cursor.execute(select_query, val) author_cursor = conn.cursor()
result = cursor.fetchone()
# Execute the Author SQL Query
author_cursor.execute(select_query, author_val)
author_result = author_cursor.fetchone()
# Make sure that the user cannot marry themselves # Make sure that the user cannot marry themselves
if member.id == ctx.author.id: if member.id == ctx.author.id:
await ctx.send("Senpaii! ˭̡̞(◞⁎˃ᆺ˂)◞*✰ You can't possibly marry yourself!") await ctx.send("Senpaii! ˭̡̞(◞⁎˃ᆺ˂)◞*✰ You can't possibly marry yourself!")
return return
# Make sure that the person is not already married to someone else within the server # Make sure that the person is not already married to someone else within the server
elif result[2] is not None: elif author_result[2] is not None:
member = guild.get_member(int(result[2])) member = guild.get_member(int(author_result[2]))
await ctx.send(f"((╬◣﹏◢)) You're already married to {member.mention}!") await ctx.send(f"((╬◣﹏◢)) You're already married to {member.mention}!")
return return
# Close the previous cursor
author_cursor.close()
# Set up new cursor for member row
member_cursor = conn.cursor()
# Execute the Member SQL Query
member_cursor.execute(select_query, member_val)
member_result = member_cursor.fetchone()
if member_result[2] is not None:
member = guild.get_member(int(member_result[2]))
await ctx.send(f"Sorry! That user is already married to {member.mention}")
return
# Send a message to the channel mentioning the author and the person they want to wed. # Send a message to the channel mentioning the author and the person they want to wed.
await ctx.send(f"{ctx.author.mention} **Proposes To** {member.mention} **Do you accept??** " await ctx.send(f"{ctx.author.mention} **Proposes To** {member.mention} **Do you accept??** "

Loading…
Cancel
Save