diff --git a/src/cogs/guild.py b/src/cogs/guild.py index 99471e7..104abfa 100644 --- a/src/cogs/guild.py +++ b/src/cogs/guild.py @@ -92,8 +92,8 @@ async def invites(self, ctx, name: str = None): """View your invitation stats""" await ctx.defer() if not name: - uuid, _ = await get_db_uuid_username_from_discord_id(ctx.author.id) - res = await String(string=uuid).invites() + uuid, username = await get_db_uuid_username_from_discord_id(ctx.author.id) + res = await String(uuid=uuid, username=username).invites() else: res = await String(string=name).invites() await ctx.respond(embed=res) diff --git a/src/func/String.py b/src/func/String.py index 2045dac..0967e92 100644 --- a/src/func/String.py +++ b/src/func/String.py @@ -16,7 +16,7 @@ months, neg_color, neutral_color, pos_color, qotd_ans_channel_id, qotd_channel_id, ticket_categories, unknown_ign_embed, rainbow_separator, guild_handle, - missing_permissions_embed) + missing_permissions_embed, member_req) from src.utils.db_utils import (delete_dnkl, select_one, get_invites) from src.utils.request_utils import (get_hypixel_player, get_mojang_profile, @@ -309,5 +309,7 @@ async def invites(self): embed.add_field(name="Total Invites", value=total_invites, inline=True) embed.add_field(name="Total Valid Invites", value=total_valid_invites, inline=True) embed.set_footer(text="Total invites and total valid invites do not include this week's invites. They are " - "updated at the end of the week.") + "updated at the end of the week.\nAn invite is considered valid if they earn " + f"2 * {format(member_req, ',d')} at the end of the week. " + "If they joined in the middle of the week, their guild experience will be scaled up.") return embed diff --git a/src/utils/calculation_utils.py b/src/utils/calculation_utils.py index f069682..427674f 100644 --- a/src/utils/calculation_utils.py +++ b/src/utils/calculation_utils.py @@ -206,25 +206,24 @@ async def is_valid_date(date: str): return False, None, None, None + async def extract_usernames(message: str): # Define regular expressions for both formats - format1_pattern = r"🎉 \*\*(?:\[(.*?)\] )?(.*?)\*\* joined the guild! \*\*They weren't invited by anyone\." - format2_pattern = r"🎉 \*\*(?:\[(.*?)\] )?(.*?)\*\* invited(?: \*\*\[(.*?)\] )?(?:\*\*)? (?:\*\*)?(.*?)\*\* to the guild!" + format1_pattern = r"🎉 \*\*(.*?)\*\* invited \*\*(.*?)\*\* to the guild!" + format2_pattern = r"🎉 \*\*(.*?)\*\* joined the guild! \*\*They weren't invited by anyone\." # Check if it matches format 1 match_format1 = re.match(format1_pattern, message) if match_format1: - username1 = match_format1.group(2) - return username1, None + username1 = match_format1.group(1) + username2 = match_format1.group(2) + return username1, username2 # Check if it matches format 2 match_format2 = re.match(format2_pattern, message) if match_format2: - username1 = match_format2.group(2) - username2 = match_format2.group(4) - if username2.startswith('['): # Check if the second username starts with '[' indicating a rank - username2 = username2.split('] ')[1] # Remove the rank from the second username - return username1, username2.strip('**') # Remove any leading or trailing '**' + username1 = match_format2.group(1) + return username1, None # If it doesn't match any format, return None for both usernames return None, None