Skip to content

Commit

Permalink
Merge pull request #152 from MiscGuild/bug_fixes
Browse files Browse the repository at this point in the history
Bug fixes
  • Loading branch information
Amxgh authored Oct 24, 2023
2 parents e49949d + 71358a4 commit a0bbda8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/cogs/tickets.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ def __init__(self, bot):
)
async def register(self, ctx, name: str):
"""Register with your IGN to sync your roles!"""
res = await Union(user=ctx.author).register(ctx, name)
res, guest_ticket = await Union(user=ctx.author).register(ctx, name)
if isinstance(res, discord.Embed):
await ctx.respond(embed=res)
if guest_ticket:
print(guest_ticket)
await ctx.followup.send(f"Head on over to <#{guest_ticket.id}>!", ephemeral=True)
if isinstance(res, String):
await ctx.respond(res)

Expand Down
10 changes: 6 additions & 4 deletions src/func/Union.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,11 @@ async def register(self, ctx, name):
ign, uuid = await get_mojang_profile(name)

if not ign:
return unknown_ign_embed
return unknown_ign_embed, None

# Filter out people impersonating staff
if ign in bot.staff_names:
return staff_impersonation_embed
return staff_impersonation_embed, None

# Fetch player & guild data
guild_data = await get_player_guild(uuid)
Expand All @@ -188,6 +188,7 @@ async def register(self, ctx, name):
await ctx.response.send_modal(modal=uiutils.ModalCreator(embed=embed, fields=fields, ign=ign, uuid=uuid, title="Player Reference",
function=validate_reference))
await ctx.author.add_roles(bot.member_role, reason="Registration - Member")
guest_ticket = None

# User is in an allied guild
elif guild_name in allies:
Expand All @@ -198,6 +199,7 @@ async def register(self, ctx, name):
gtag = "" if "tag" not in guild_data else guild_data["tag"]
if not ctx.author.nick or gtag not in ctx.author.nick:
ign = ign + " " + f"[{gtag}]"
guest_ticket = None

# User is a guest
else:
Expand All @@ -209,7 +211,7 @@ async def register(self, ctx, name):
await ticket.edit(name=f"join-request-{ign}", topic=f"{ctx.author.id}|",
category=discord.utils.get(ctx.guild.categories,
name=ticket_categories["registrees"]))

guest_ticket = ticket
class Join_Misc_Buttons(discord.ui.Button):
def __init__(self, button: list):
"""
Expand Down Expand Up @@ -262,7 +264,7 @@ async def callback(self, interaction: discord.Interaction):
await ctx.author.remove_roles(bot.new_member_role, reason="Register")
await ctx.author.edit(nick=ign)

return embed if guild_name != guild_handle else None
return (embed, guest_ticket) if guild_name != guild_handle else (None, None)

async def add(self, ctx):
if ctx.channel.category.name not in ticket_categories.values():
Expand Down
2 changes: 2 additions & 0 deletions src/utils/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"turbo_kart_racers": "Turbo Kart Racers",
"pit": "The Pit",
"murder_mystery": "Murder Mystery",
"copsvcrims": "Cops and Crims",
"miscellaneous": "Miscellaneous",
"discord": "Discord",
"other": "Other"
Expand All @@ -92,6 +93,7 @@
"turbo_kart_racers": "<:TurboKartRacers64:846306861950304267>",
"pit": "<:pit:851361342744690728>",
"murder_mystery": "<:MurderMystery64:823036899974447105>",
"copsvcrims": "<:CVC64:846306846717378560>",
"miscellaneous": "<:Misc:540990817872117780>",
"discord": "<:discord:977349801412788266>",
"other": "❓"
Expand Down
2 changes: 1 addition & 1 deletion src/utils/referral_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ async def generate_rank_upgrade(weekly_invites : list):
# A player gets 7 entries for every valid invite they have made
total_invitations = 0
for uuid, invitations in weekly_invites:
entries[uuid] = entries[uuid] + (len(invitations)*7)
entries[uuid] = entries[uuid] + (len(invitations)*7) if uuid in entries else (len(invitations)*7)
total_invitations += len(invitations)

weighted_entries = [uuid for uuid, weight in entries.items() for _ in range(weight)]
Expand Down

0 comments on commit a0bbda8

Please sign in to comment.