Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Apr 5, 2024
1 parent ed7e092 commit 6411f2c
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions commands/birthdays.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
if TYPE_CHECKING:
from bot import ChouetteBot


# Define command group based on the Group class
class Birthday(app_commands.Group):
# Set command group name and description
Expand All @@ -23,7 +24,13 @@ def __init__(self):
name="add",
description="Permit the user to register his birthday",
)
async def add(self, interaction: discord.Interaction[ChouetteBot], day: int, month: int, year: Optional[int]):
async def add(
self,
interaction: discord.Interaction[ChouetteBot],
day: int,
month: int,
year: Optional[int],
):
if not year:
year = 1
try:
Expand All @@ -37,7 +44,7 @@ async def add(self, interaction: discord.Interaction[ChouetteBot], day: int, mon
user_info = table()
user_info["name"] = user_name
user_info["birthday"] = birth_date
birthdays.update({user_id:user_info})
birthdays.update({user_id: user_info})
save_birthdays(birthdays)
await interaction.response.send_message("Anniversaire enregistré !", ephemeral=True)
else:
Expand All @@ -48,27 +55,32 @@ async def add(self, interaction: discord.Interaction[ChouetteBot], day: int, mon
ephemeral=True,
)


# Commande pour modifier un anniversaire
@app_commands.command(
name="modify",
description="Permit the user to modify his birthday",
)
async def modify(self, interaction: discord.Interaction[ChouetteBot], day: int, month: int, year: Optional[int]):
async def modify(
self,
interaction: discord.Interaction[ChouetteBot],
day: int,
month: int,
year: Optional[int],
):
if not year:
year = 1
try:
birth_date = date(year, month, day)
except ValueError:
pass
pass
user_name = str(interaction.user.name)
user_id = str(interaction.user.id)
birthdays = load_birthdays()
if user_id in birthdays:
user_info = table()
user_info["name"] = user_name
user_info["birthday"] = birth_date
birthdays.update({user_id:user_info})
birthdays.update({user_id: user_info})
save_birthdays(birthdays)
await interaction.response.send_message("Anniversaire modifié !", ephemeral=True)
else:
Expand All @@ -92,4 +104,6 @@ async def remove_birthday(interaction: discord.Interaction[ChouetteBot]):
save_birthdays(birthdays)
await interaction.response.send_message("Anniversaire supprimé !")
else:
await interaction.response.send_message("Vous n'avez pas d'anniversaire enregistré.", ephemeral=True)
await interaction.response.send_message(
"Vous n'avez pas d'anniversaire enregistré.", ephemeral=True
)

0 comments on commit 6411f2c

Please sign in to comment.