Compare commits

...

3 commits

Author SHA1 Message Date
e559db9f10
feat(aurora): moved the converter commands to their own convert command group
Some checks failed
Actions / Build Documentation (MkDocs) (pull_request) Successful in 28s
Actions / Lint Code (Ruff & Pylint) (pull_request) Failing after 40s
2024-08-12 20:46:40 -04:00
9e2bcf9b00
feat(aurora): added datetime command 2024-08-12 20:44:12 -04:00
4ec065e438
fix(aurora): fixed a NotFound error being thrown to the console 2024-08-12 20:40:10 -04:00
6 changed files with 51 additions and 7 deletions

View file

@ -1224,7 +1224,31 @@ class Aurora(commands.Cog):
error("Please provide a valid GalacticBot moderation export file.")
)
@aurora.command(aliases=["tdc", "td", "timedeltaconvert"])
@aurora.group(autohelp=True, name="convert")
async def aurora_convert(self, ctx: commands.Context):
"""Convert strings to various Python objects."""
pass
@aurora_convert.command(aliases=["dt"])
async def datetime(self, ctx: commands.Context, *, date: str) -> None:
"""Convert a string to a datetime object.
This command converts a date to a [`datetime`](https://docs.python.org/3/library/datetime.html#datetime.datetime) Python object.
**Example usage**
`[p]aurora datetime 08/20/2024`
**Output**
`2024-08-20 12:00:00`"""
try:
parsed_date = parse(date)
await ctx.send(f"`{parsed_date}`")
except (ParserError, OverflowError) as e:
if e == ParserError:
await ctx.send(error("Invalid date format!"))
if e == OverflowError:
await ctx.send(error("Date is too far in the future!"))
@aurora_convert.command(aliases=["td"])
async def timedelta(self, ctx: commands.Context, *, duration: str) -> None:
"""Convert a string to a timedelta.
@ -1241,7 +1265,7 @@ class Aurora(commands.Cog):
return
await ctx.send(f"`{parsed_time}`")
@aurora.command(aliases=["rdc", "rd", "relativedeltaconvert"])
@aurora_convert.command(aliases=["rd"])
async def relativedelta(self, ctx: commands.Context, *, duration: str) -> None:
"""Convert a string to a relativedelta.

View file

@ -1,4 +1,5 @@
from discord import ButtonStyle, Interaction, Message, ui
from discord.errors import NotFound
from redbot.core import commands
from redbot.core.utils.chat_formatting import error
@ -14,7 +15,10 @@ class Addrole(ui.View):
self.timeout = timeout
async def on_timeout(self):
try:
await self.message.edit(view=None)
except NotFound:
pass
@ui.select(cls=ui.RoleSelect, placeholder="Select a role", min_values=0, max_values=25)
async def addrole_select(self, interaction: Interaction, select: ui.RoleSelect):

View file

@ -1,4 +1,5 @@
from discord import ButtonStyle, Interaction, Message, ui
from discord.errors import NotFound
from redbot.core import commands
from ..utilities.config import config
@ -14,7 +15,10 @@ class Guild(ui.View):
self.timeout = timeout
async def on_timeout(self):
try:
await self.message.edit(view=None)
except NotFound:
pass
@ui.button(label="Show Moderator", style=ButtonStyle.green, row=0)
async def show_moderator(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument

View file

@ -1,4 +1,5 @@
from discord import ButtonStyle, Interaction, Message, ui
from discord.errors import NotFound
from redbot.core import commands
from redbot.core.utils.chat_formatting import error
@ -14,7 +15,10 @@ class Immune(ui.View):
self.timeout = timeout
async def on_timeout(self):
try:
await self.message.edit(view=None)
except NotFound:
pass
@ui.select(cls=ui.RoleSelect, placeholder="Select a role", min_values=0, max_values=25)
async def immune_select(self, interaction: Interaction, select: ui.RoleSelect):

View file

@ -1,4 +1,5 @@
from discord import ButtonStyle, Interaction, Message, ui
from discord.errors import NotFound
from redbot.core import commands
from ..utilities.config import config
@ -14,7 +15,10 @@ class Overrides(ui.View):
self.timeout = timeout
async def on_timeout(self):
try:
await self.message.edit(view=None)
except NotFound:
pass
@ui.button(label="Auto Evidence Format", style=ButtonStyle.green, row=0)
async def auto_evidenceformat(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument

View file

@ -1,4 +1,5 @@
from discord import ButtonStyle, Interaction, Message, ui
from discord.errors import NotFound
from redbot.core import commands
from ..models.type import Type
@ -15,7 +16,10 @@ class Types(ui.View):
self.timeout = timeout
async def on_timeout(self):
try:
await self.message.edit(view=None)
except NotFound:
pass
@ui.button(label="Show in History", style=ButtonStyle.green, row=0)
async def show_in_history(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument