diff --git a/src/cogs/hypixel.py b/src/cogs/hypixel.py index f6c2636..350ec0e 100644 --- a/src/cogs/hypixel.py +++ b/src/cogs/hypixel.py @@ -74,12 +74,26 @@ async def dnkl_add(self, ctx, name: str): @option( name="name", description="The Minecraft username of the player who you want to remove from the do-not-kick-list", - required=True, + required=False, input_type=str ) - async def dnkl_remove(self, ctx, name: str): + @option( + name="uuid", + description="The UUID of the player who you want to remove from the do-not-kick-list", + required=False, + input_type=str + ) + async def dnkl_remove(self, ctx, name: str = None, uuid: str = None): """Remove a player from the do-not-kick-list""" - await ctx.respond(await String(string=name).dnklremove()) + if not name and not uuid: + await ctx.respond("Please provide either the username or the UUID of the player you want to remove.") + return + if name and not uuid and len(name) > 16: + uuid = name + if uuid: + await ctx.respond(await String(uuid=uuid).dnklremove()) + else: + await ctx.respond(await String(string=name).dnklremove()) @bridge.bridge_command(aliases=['dnkllist', 'dnkll']) async def dnkl_list(self, ctx): diff --git a/src/func/General.py b/src/func/General.py index 0f6eaf5..998d8a8 100644 --- a/src/func/General.py +++ b/src/func/General.py @@ -56,8 +56,8 @@ async def dnkllist(ctx): # Create embed content = "" for _set in rows: - _, _, username = _set - content += f"{username}\n" + _, uuid, username = _set + content += f"{username} ||{uuid}||\n" return discord.Embed(title="The people on the do-not-kick-list are as follows:", description=content, color=neutral_color).set_footer(text=f"Total: {len(content.split())}") diff --git a/src/func/String.py b/src/func/String.py index ee2bb0f..b1dd9eb 100644 --- a/src/func/String.py +++ b/src/func/String.py @@ -206,8 +206,12 @@ async def dnkladd(self, ctx): dnkl_embed = await dnkl_application(ign, uuid, ctx.channel, ctx.author, weekly_gexp) async def dnklremove(self): - ign, uuid = await get_mojang_profile(self.string) - row = await select_one("SELECT * FROM dnkl WHERE username = (?)", (ign,)) + if self.string: + ign, uuid = await get_mojang_profile(self.string) + else: + ign, uuid = await get_name_by_uuid(self.uuid), self.uuid + + row = await select_one("SELECT * FROM dnkl WHERE uuid = (?)", (uuid,)) if not row: return "This player is not on the do-not-kick-list!" diff --git a/src/utils/request_utils.py b/src/utils/request_utils.py index 28c6b5b..252e262 100644 --- a/src/utils/request_utils.py +++ b/src/utils/request_utils.py @@ -66,6 +66,8 @@ async def get_hypixel_player(name: str = None, uuid: str = None): else: resp = await get_json_response(f"https://api.hypixel.net/player?key={api_key}&uuid={uuid}") + if not resp: + return None # Player doesn't exist if "player" not in resp or not resp["player"]: return None