Adding commentary

pull/8/head
sgoudham 4 years ago
parent b143d435e8
commit 8ec264ea54

@ -11,24 +11,29 @@ import db
from settings import colour_list from settings import colour_list
# Sets up the embed for the marriage info
def marriageInfo(target, marriedUser, marriedDate, currentDate, married): def marriageInfo(target, marriedUser, marriedDate, currentDate, married):
# Make sure that non-users can still use the marriage
if not married: if not married:
# Set up the fields for the embed
fields = [("Married To", "No One", False), fields = [("Married To", "No One", False),
("Marriage Date", "N/A", False), ("Marriage Date", "N/A", False),
("Days Married", "N/A", False)] ("Days Married", "N/A", False)]
else: else:
# Calculate the days married
marriedTime = datetime.datetime.strptime(marriedDate, "%a, %b %d, %Y") marriedTime = datetime.datetime.strptime(marriedDate, "%a, %b %d, %Y")
currentTime = datetime.datetime.strptime(currentDate, "%a, %b %d, %Y") currentTime = datetime.datetime.strptime(currentDate, "%a, %b %d, %Y")
delta = currentTime - marriedTime delta = currentTime - marriedTime
# Set up the fields for the embed
fields = [("Married To", marriedUser.mention, False), fields = [("Married To", marriedUser.mention, False),
("Marriage Date", marriedDate, False), ("Marriage Date", marriedDate, False),
("Days Married", delta.days, False)] ("Days Married", delta.days, False)]
# Set the title, colour, timestamp and thumbnail
embed = Embed(title=f"{target.name}'s Marriage Information", embed = Embed(title=f"{target.name}'s Marriage Information",
colour=Colour(int(random.choice(colour_list))), colour=Colour(int(random.choice(colour_list))),
timestamp=datetime.datetime.utcnow()) timestamp=datetime.datetime.utcnow())
embed.set_thumbnail(url=target.avatar_url) embed.set_thumbnail(url=target.avatar_url)
# Add fields to the embed # Add fields to the embed
@ -254,15 +259,18 @@ class Relationship(commands.Cog):
cursor.execute(select_query, val) cursor.execute(select_query, val)
result = cursor.fetchone() result = cursor.fetchone()
# Set empty values for non-married users
if result[2] is None: if result[2] is None:
married = False married = False
marriedUser = "" marriedUser = ""
marriedDate = "" marriedDate = ""
# Set the member, date married and setting married status
else: else:
marriedUser = guild.get_member(int(result[2])) marriedUser = guild.get_member(int(result[2]))
marriedDate = result[3] marriedDate = result[3]
married = True married = True
# Get the current date of the message sent by the user
currentDate = ctx.message.created_at.strftime("%a, %b %d, %Y") currentDate = ctx.message.created_at.strftime("%a, %b %d, %Y")
embed = marriageInfo(target, marriedUser, marriedDate, currentDate, married) embed = marriageInfo(target, marriedUser, marriedDate, currentDate, married)

Loading…
Cancel
Save