diff --git a/src/cogs/general.py b/src/cogs/general.py index c6e4abf..40d3a67 100644 --- a/src/cogs/general.py +++ b/src/cogs/general.py @@ -57,6 +57,15 @@ async def callback(self, interaction: discord.Interaction): await ctx.send_modal(modal=ModalCreator()) + @commands.slash_command() + @option( + name="Member", + description="The discord user whose minecraft ign you'd like to find", + required=True, + input_type=discord.Member + ) + async def whois(self, ctx, member: discord.Member): + await ctx.respond(embed=await Union(member).whois()) def setup(bot): bot.add_cog(General(bot)) diff --git a/src/func/General.py b/src/func/General.py index 7aa62d5..5783c0b 100644 --- a/src/func/General.py +++ b/src/func/General.py @@ -98,7 +98,7 @@ async def rolecheck(ctx, send_ping: bool): "gexp": sum(player["expHistory"].values())} await ctx.send("If you see the bot is stuck on a member along with an error message, " - "forcesync member the bot is stuck on.") + "forcesync member the bot is stuck on.") bot.admin_ids = [member.id for member in bot.admin.members] for discord_member in discord_members: # Do not check admins and bots @@ -122,8 +122,7 @@ async def rolecheck(ctx, send_ping: bool): elif weekly_exp < active_req and bot.active_role in discord_member.roles: # Doesn't meet active req await discord_member.remove_roles(bot.active_role) - if (nick != username and bot.active_role not in discord_member.roles) or ( - nick != username and not has_tag_permission): + if nick != username and not has_tag_permission: await discord_member.edit(nick=username) # Edit roles diff --git a/src/func/Union.py b/src/func/Union.py index 331baef..b29dc5c 100644 --- a/src/func/Union.py +++ b/src/func/Union.py @@ -11,7 +11,7 @@ pos_color, registration_channel_id, staff_impersonation_embed, ticket_categories, unknown_ign_embed, join_request_embed) -from src.utils.db_utils import update_member, insert_new_member +from src.utils.db_utils import update_member, insert_new_member, get_db_uuid_username_from_discord_id from src.utils.discord_utils import (create_ticket, has_tag_perms, is_linked_discord) from src.utils.request_utils import (get_gtag, get_hypixel_player, @@ -85,7 +85,6 @@ async def sync(self, ctx, name: str, tag: str = None, is_fs=False): if not ign: return unknown_ign_embed - # Initialize vars for storing changes roles_to_add = [] roles_to_remove = [bot.processing] @@ -288,3 +287,15 @@ async def avatar(self): embed = discord.Embed( title=f"{self.user}'s avatar:", color=neutral_color) return embed.set_image(url=self.user.avatar) + + async def whois(self): + uuid, username = await get_db_uuid_username_from_discord_id(self.user.id) + embed = discord.Embed( + title=username, + description=f"Discord Username: {self.user.name}\n" + f"Discord Nick: {self.user.nick}", + color=neutral_color + ) + embed.set_thumbnail(url=f'https://minotar.net/helm/{uuid}/512.png') + embed.set_footer(text=f"UUID: {uuid}") + return embed diff --git a/src/utils/discord_utils.py b/src/utils/discord_utils.py index 55786d8..b8a6670 100644 --- a/src/utils/discord_utils.py +++ b/src/utils/discord_utils.py @@ -6,6 +6,7 @@ from src.utils.consts import (config, log_channel_id, neutral_color, ticket_categories, guild_handle) +from src.utils.db_utils import check_uuid_in_db from src.utils.request_utils import get_mojang_profile from src.utils.ticket_utils import * from src.utils.ticket_utils.tickets import name_grabber @@ -139,6 +140,23 @@ async def has_tag_perms(user: discord.User): return any(role in user.roles for role in bot.tag_allowed_roles) +async def update_recruiter_role(uuid: str, invites: int): + user_id = await check_uuid_in_db(uuid) + if not user_id: + return + member_ids = [x.id for x in bot.guild.members] + if user_id not in member_ids: + return + user = bot.guild.get_member(user_id) + if invites > 5: + await user.add_roles(bot.recruiter) + else: + await user.remove_roles(bot.recruiter) + return + + + + @tasks.loop(count=1) async def after_cache_ready(): # Set owner id(s) and guild @@ -158,12 +176,13 @@ async def after_cache_ready(): bot.active_role = discord.utils.get(bot.guild.roles, name="Active") bot.ally = discord.utils.get(bot.guild.roles, name="Ally") bot.server_booster = discord.utils.get(bot.guild.roles, name="Server Booster") - bot.rich_kid = discord.utils.get(bot.guild.roles, name="Rich Kid") + bot.rich_kid = discord.utils.get(bot.guild.roles, name="Event Sponsor") bot.gvg = discord.utils.get(bot.guild.roles, name="GvG Team") bot.giveaways_events = discord.utils.get(bot.guild.roles, name="Giveaways/Events") bot.veteran = discord.utils.get(bot.guild.roles, name="Veteran") + bot.recruiter = discord.utils.get(bot.guild.roles, name="Recruiter") bot.tag_allowed_roles = (bot.active_role, bot.staff, bot.former_staff, - bot.server_booster, bot.rich_kid, bot.gvg, bot.veteran) + bot.server_booster, bot.rich_kid, bot.gvg, bot.veteran, bot.recruiter) from src.utils.discord_utils import name_grabber bot.staff_names = [(await get_mojang_profile(await name_grabber(member)))[0] for member in bot.staff.members] diff --git a/src/utils/loop_utils.py b/src/utils/loop_utils.py index 76fa153..42a5e07 100644 --- a/src/utils/loop_utils.py +++ b/src/utils/loop_utils.py @@ -8,6 +8,7 @@ from src.func.Integer import Integer from src.utils.consts import weekly_lb_channel, daily_lb_channel from src.utils.db_utils import (connect_db, select_all) +from src.utils.discord_utils import update_recruiter_role from src.utils.giveaway_utils import roll_giveaway from src.utils.referral_utils import check_invitation_validity, generate_rank_upgrade @@ -70,6 +71,7 @@ async def update_invites(): valid_invites = await check_invitation_validity(weekly_uuids) weekly_invitations.append((inviter_uuid, valid_invites)) total_valid_invites = total_valid_invites + len(valid_invites) + await update_recruiter_role(inviter_uuid, len(valid_invites)) await bot.db.execute( "UPDATE invites SET total_invites = (?), total_valid_invites = (?), current_invitee_uuids = '' WHERE inviter_uuid = (?)", (total_invites, total_valid_invites, inviter_uuid))