Compare commits
3 commits
7c8aaba309
...
e559db9f10
Author | SHA1 | Date | |
---|---|---|---|
e559db9f10 | |||
9e2bcf9b00 | |||
4ec065e438 |
6 changed files with 51 additions and 7 deletions
|
@ -1224,7 +1224,31 @@ class Aurora(commands.Cog):
|
||||||
error("Please provide a valid GalacticBot moderation export file.")
|
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:
|
async def timedelta(self, ctx: commands.Context, *, duration: str) -> None:
|
||||||
"""Convert a string to a timedelta.
|
"""Convert a string to a timedelta.
|
||||||
|
|
||||||
|
@ -1241,7 +1265,7 @@ class Aurora(commands.Cog):
|
||||||
return
|
return
|
||||||
await ctx.send(f"`{parsed_time}`")
|
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:
|
async def relativedelta(self, ctx: commands.Context, *, duration: str) -> None:
|
||||||
"""Convert a string to a relativedelta.
|
"""Convert a string to a relativedelta.
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from discord import ButtonStyle, Interaction, Message, ui
|
from discord import ButtonStyle, Interaction, Message, ui
|
||||||
|
from discord.errors import NotFound
|
||||||
from redbot.core import commands
|
from redbot.core import commands
|
||||||
from redbot.core.utils.chat_formatting import error
|
from redbot.core.utils.chat_formatting import error
|
||||||
|
|
||||||
|
@ -14,7 +15,10 @@ class Addrole(ui.View):
|
||||||
self.timeout = timeout
|
self.timeout = timeout
|
||||||
|
|
||||||
async def on_timeout(self):
|
async def on_timeout(self):
|
||||||
await self.message.edit(view=None)
|
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)
|
@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):
|
async def addrole_select(self, interaction: Interaction, select: ui.RoleSelect):
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from discord import ButtonStyle, Interaction, Message, ui
|
from discord import ButtonStyle, Interaction, Message, ui
|
||||||
|
from discord.errors import NotFound
|
||||||
from redbot.core import commands
|
from redbot.core import commands
|
||||||
|
|
||||||
from ..utilities.config import config
|
from ..utilities.config import config
|
||||||
|
@ -14,7 +15,10 @@ class Guild(ui.View):
|
||||||
self.timeout = timeout
|
self.timeout = timeout
|
||||||
|
|
||||||
async def on_timeout(self):
|
async def on_timeout(self):
|
||||||
await self.message.edit(view=None)
|
try:
|
||||||
|
await self.message.edit(view=None)
|
||||||
|
except NotFound:
|
||||||
|
pass
|
||||||
|
|
||||||
@ui.button(label="Show Moderator", style=ButtonStyle.green, row=0)
|
@ui.button(label="Show Moderator", style=ButtonStyle.green, row=0)
|
||||||
async def show_moderator(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
|
async def show_moderator(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from discord import ButtonStyle, Interaction, Message, ui
|
from discord import ButtonStyle, Interaction, Message, ui
|
||||||
|
from discord.errors import NotFound
|
||||||
from redbot.core import commands
|
from redbot.core import commands
|
||||||
from redbot.core.utils.chat_formatting import error
|
from redbot.core.utils.chat_formatting import error
|
||||||
|
|
||||||
|
@ -14,7 +15,10 @@ class Immune(ui.View):
|
||||||
self.timeout = timeout
|
self.timeout = timeout
|
||||||
|
|
||||||
async def on_timeout(self):
|
async def on_timeout(self):
|
||||||
await self.message.edit(view=None)
|
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)
|
@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):
|
async def immune_select(self, interaction: Interaction, select: ui.RoleSelect):
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from discord import ButtonStyle, Interaction, Message, ui
|
from discord import ButtonStyle, Interaction, Message, ui
|
||||||
|
from discord.errors import NotFound
|
||||||
from redbot.core import commands
|
from redbot.core import commands
|
||||||
|
|
||||||
from ..utilities.config import config
|
from ..utilities.config import config
|
||||||
|
@ -14,7 +15,10 @@ class Overrides(ui.View):
|
||||||
self.timeout = timeout
|
self.timeout = timeout
|
||||||
|
|
||||||
async def on_timeout(self):
|
async def on_timeout(self):
|
||||||
await self.message.edit(view=None)
|
try:
|
||||||
|
await self.message.edit(view=None)
|
||||||
|
except NotFound:
|
||||||
|
pass
|
||||||
|
|
||||||
@ui.button(label="Auto Evidence Format", style=ButtonStyle.green, row=0)
|
@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
|
async def auto_evidenceformat(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from discord import ButtonStyle, Interaction, Message, ui
|
from discord import ButtonStyle, Interaction, Message, ui
|
||||||
|
from discord.errors import NotFound
|
||||||
from redbot.core import commands
|
from redbot.core import commands
|
||||||
|
|
||||||
from ..models.type import Type
|
from ..models.type import Type
|
||||||
|
@ -15,7 +16,10 @@ class Types(ui.View):
|
||||||
self.timeout = timeout
|
self.timeout = timeout
|
||||||
|
|
||||||
async def on_timeout(self):
|
async def on_timeout(self):
|
||||||
await self.message.edit(view=None)
|
try:
|
||||||
|
await self.message.edit(view=None)
|
||||||
|
except NotFound:
|
||||||
|
pass
|
||||||
|
|
||||||
@ui.button(label="Show in History", style=ButtonStyle.green, row=0)
|
@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
|
async def show_in_history(self, interaction: Interaction, button: ui.Button): # pylint: disable=unused-argument
|
||||||
|
|
Loading…
Reference in a new issue