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

Just use app_commands.Range. #521

Closed
wants to merge 5 commits into from
Closed
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
16 changes: 8 additions & 8 deletions ballsdex/core/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,14 +414,6 @@ async def on_command_error(
)
return

if isinstance(exception, commands.MissingPermissions):
missing_perms = ", ".join(exception.missing_permissions)
await context.send(
f"You are missing the following permissions: `{missing_perms}`."
" You need those permissions to run this command."
)
return

return

if isinstance(exception, commands.CommandInvokeError):
Expand Down Expand Up @@ -463,6 +455,14 @@ async def send(content: str):
)
return

if isinstance(error, app_commands.MissingRole):
missing_roles = ",".join(error.missing_role)
await send(
f"You are missing the following roles: `{missing_roles}`."
" You need those roles to run this command."
)
return

return

if isinstance(error, app_commands.TransformerError):
Expand Down
2 changes: 1 addition & 1 deletion ballsdex/core/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async def inventory_privacy(
elif privacy_policy == PrivacyPolicy.FRIENDS:
if not await interacting_player.is_friend(player):
await interaction.followup.send(
"This users inventory can only be viewed from users they have added as friends.",
"This user's inventory can only be viewed from users they have added as friends.",
ephemeral=True,
)
return False
Expand Down
15 changes: 1 addition & 14 deletions ballsdex/packages/admin/balls.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ async def spawn(
interaction: discord.Interaction[BallsDexBot],
countryball: BallTransform | None = None,
channel: discord.TextChannel | None = None,
n: int = 1,
n: app_commands.Range[int, 1, 100] = 1,
):
"""
Force spawn a random or specified countryball.
Expand All @@ -123,19 +123,6 @@ async def spawn(
if interaction.response.is_done():
return

if n < 1:
await interaction.response.send_message(
"`n` must be superior or equal to 1.", ephemeral=True
)
return
if n > 100:
await interaction.response.send_message(
f"That doesn't seem reasonable to spawn {n} times, "
"the bot will be rate-limited. Try something lower than 100.",
ephemeral=True,
)
return

if n > 1:
await self._spawn_bomb(
interaction, countryball, channel or interaction.channel, n # type: ignore
Expand Down
Loading