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

isitreadonlyfriday: docs and input validation #279

Merged
merged 3 commits into from
Aug 9, 2024
Merged
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
21 changes: 18 additions & 3 deletions isitreadonlyfriday/isitreadonlyfriday.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,31 @@ async def get_isitreadonlyfriday(self, offset: int) -> discord.Embed:

@commands.command()
async def isitreadonlyfriday(self, ctx: commands.Context, offset: int = 0) -> None:
"""Returns isitreadonlyfriday result with given UTC offset (default 0, range -12 to 12)"""
"""Tells you if it's read-only Friday!

Accepts optional UTC offset (default 0, range -12 to 12).
"""

if offset not in range(-12, 13):
await ctx.send("Offset must be between -12 and 12.")
return

embed = await self.get_isitreadonlyfriday(offset)
await ctx.send(embed=embed)

@app_commands.command(name="isitreadonlyfriday")
async def app_isitreadonlyfriday(
self, interaction: discord.Interaction, offset: int = 0
self,
interaction: discord.Interaction,
offset: app_commands.Range[int, -12, 12] = 0,
):
"""Returns isitreadonlyfriday result with given UTC offset (default 0, range -12 to 12)"""
"""Tells you if it's read-only Friday!

Paramters
----------
offset: int
UTC offset (default 0, range -12 to 12)
"""

embed = await self.get_isitreadonlyfriday(offset)
await interaction.response.send_message(embed=embed)
Expand Down
Loading