Skip to content

Commit

Permalink
Merge pull request #190 from MiscGuild/bug_fix
Browse files Browse the repository at this point in the history
Bug fix
  • Loading branch information
Amxgh authored May 25, 2024
2 parents 3b5dfea + 3d0f880 commit 36f29c3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 7 deletions.
20 changes: 17 additions & 3 deletions src/cogs/hypixel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions src/func/General.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())}")
Expand Down
8 changes: 6 additions & 2 deletions src/func/String.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!"
Expand Down
2 changes: 2 additions & 0 deletions src/utils/request_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 36f29c3

Please sign in to comment.