Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix #190

Merged
merged 4 commits into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading