Skip to content

Commit

Permalink
Merge pull request #107 from Zalk0/dev
Browse files Browse the repository at this point in the history
Skyblock refactoring + bug fixes + dep upgrade
  • Loading branch information
gylfirst authored Nov 25, 2024
2 parents 9fc2db6 + ef6c68e commit 9083f37
Show file tree
Hide file tree
Showing 10 changed files with 259 additions and 103 deletions.
72 changes: 72 additions & 0 deletions .github/ISSUE_TEMPLATE/bug.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Bug report
description: Report a bug to help us improve the bot
title: "[BUG] Concise description of the issue"
labels: bug
assignees:
- Zalk0
- gylfirst

body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this bug report!
- type: input
id: title
attributes:
label: Bug Title
description: A clear and concise title of what the bug is.
placeholder: Bug title

- type: textarea
id: description
attributes:
label: Description
description: A clear and concise description of what the bug is.
placeholder: Describe the bug

- type: textarea
id: steps
attributes:
label: Steps to Reproduce
description: |
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
placeholder: Steps to reproduce the bug

- type: textarea
id: expected
attributes:
label: Expected behavior
description: A clear and concise description of what you expected to happen.
placeholder: Expected behavior

- type: textarea
id: actual
attributes:
label: Actual behavior
description: A clear and concise description of what actually happened.
placeholder: Actual behavior

- type: input
id: environment
attributes:
label: Environment
description: |
Provide details about the environment running the bot:
- OS and version: [e.g. Windows, MacOS, Linux]
- Technology: [e.g. Docker, Git clone]
- Python version: [e.g. 3.9.5] (if not using Docker)
- Bot version [e.g. Docker image tag or git commit hash]
placeholder: Environment details

- type: textarea
id: additional
attributes:
label: Additional context
description: Add any other context about the problem here.
placeholder: Additional context
41 changes: 41 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Feature request
description: Suggest an idea for this project
title: "[Feature Request]: Concise description of the feature"
labels: enhancement
assignees:
- Zalk0
- gylfirst

body:
- type: markdown
attributes:
value: |
Thanks for taking the time to open a feature request! Please provide us with the following information:
- type: input
id: feature
attributes:
label: Feature description
description: A clear and concise description of what the feature is.
placeholder: Describe the feature you would like to see

- type: textarea
id: motivation
attributes:
label: Motivation
description: Please explain why this feature should be implemented and how it would be used.
placeholder: Explain the motivation behind this feature request

- type: textarea
id: alternatives
attributes:
label: Alternatives
description: Describe any alternative solutions or features you've considered.
placeholder: Describe any alternative solutions or features

- type: input
id: additional-context
attributes:
label: Additional context
description: Add any other context or screenshots about the feature request here.
placeholder: Add any other context or screenshots
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repos:

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.7.3
rev: v0.8.0
hooks:
# Run the linter.
- id: ruff
Expand Down
2 changes: 2 additions & 0 deletions chouette/commands/skyblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ async def spider(self, interaction: discord.Interaction[ChouetteBot]) -> None:
@app_commands.command(name="link")
@app_commands.rename(pseudo="pseudo_mc")
@app_commands.describe(pseudo="Ton pseudo Minecraft", profile="Ton profil Skyblock préféré")
# Cooldown 1 use per 60 seconds
@app_commands.checks.cooldown(rate=1, per=60)
async def link(
self, interaction: discord.Interaction[ChouetteBot], pseudo: str, profile: str | None
):
Expand Down
16 changes: 13 additions & 3 deletions chouette/commands_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async def on_command_error(
bot_perms = ", ".join(error.missing_permissions)
interaction.client.bot_logger.error(
f"{interaction.client.user} is missing {bot_perms} "
f"to do {interaction.command.name} in #{interaction.channel}"
f"to do /{interaction.command.qualified_name} in #{interaction.channel}"
)
if len(error.missing_permissions) == 1:
await interaction.response.send_message(
Expand All @@ -67,7 +67,7 @@ async def on_command_error(
user_perms = ", ".join(error.missing_permissions)
interaction.client.bot_logger.error(
f"{interaction.user} is missing {user_perms} "
f"to do {interaction.command.name} in #{interaction.channel}"
f"to do /{interaction.command.qualified_name} in #{interaction.channel}"
)
if len(error.missing_permissions) == 1:
await interaction.response.send_message(
Expand All @@ -80,9 +80,19 @@ async def on_command_error(
ephemeral=True,
)
return
if isinstance(error, discord.app_commands.CommandOnCooldown):
interaction.client.bot_logger.error(
f"{interaction.user} tried to use /{interaction.command.qualified_name} in "
f"#{interaction.channel.name} but the command is in cooldown for {error.retry_after:.0f}s",
)
await interaction.response.send_message(
f"Vous devez attendre {error.retry_after:.0f} secondes avant de réutiliser cette commande.",
ephemeral=True,
)
return
if isinstance(error, discord.app_commands.CheckFailure):
interaction.client.bot_logger.error(
f"{interaction.user} tried to do {interaction.command.name} "
f"{interaction.user} tried to do /{interaction.command.qualified_name} "
f"in #{interaction.channel}\n{SPACES}{error}"
)
await interaction.response.send_message(
Expand Down
15 changes: 8 additions & 7 deletions chouette/utils/hypixel_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ def experience_to_level(
Calcule le niveau correspondant à une quantité donnée d'expérience cumulative.
Args:
type_xp: Le type d'expérience pour lequel calculer le niveau (compétence, type de slayer, donjon).
Pour `slayer_type`, utilisez l'un des suivants: slayer_zombie, slayer_spider, slayer_web, slayer_vampire.
xp_amount: La quantité d'expérience cumulée.
max_level: Le niveau maximum
`type_xp`: Le type d'expérience pour lequel calculer le niveau (compétence, type de slayer, donjon).
Pour `slayer_type`, utilisez l'un des suivants: `slayer_zombie`, `slayer_spider`, `slayer_wolf`, `slayer_enderman`, `slayer_blaze`,` slayer_vampire`.
`xp_amount`: La quantité d'expérience cumulée.
`max_level`: Le niveau maximum
Returns:
level: Le niveau correspondant à la quantité donnée d'expérience cumulée.
`level`: Le niveau correspondant à la quantité donnée d'expérience cumulée.
`overflow`: L'expérience restante pour atteindre le prochain niveau.
"""
skill_xp_data: list[int] = [
0,
Expand Down Expand Up @@ -187,7 +188,7 @@ def experience_to_level(
elif type_xp == "slayer_spider":
xp_data = slayer_xp_data[1]
# Slayer Wolf/Enderman/Blaze
elif type_xp == "slayer_web":
elif type_xp in ["slayer_wolf", "slayer_enderman", "slayer_blaze"]:
xp_data = slayer_xp_data[2]
# Slayer Vampire
elif type_xp == "slayer_vampire":
Expand All @@ -200,5 +201,5 @@ def experience_to_level(
return max_level, xp_amount - xp
if xp_amount <= xp:
previous_xp = xp_data[level - 1]
return level - 1 + (xp_amount - previous_xp) / (xp - previous_xp), None
return level - 1 + (xp_amount - previous_xp) / (xp - previous_xp), 0
return len(xp_data) - 1, xp_amount - xp_data[-1]
Loading

0 comments on commit 9083f37

Please sign in to comment.