fix(aurora): fixed an error in the /edit
command
This commit is contained in:
parent
46c1cf53bf
commit
5cd0ef61cb
1 changed files with 21 additions and 22 deletions
|
@ -37,7 +37,7 @@ from .utilities.config import config, register_config
|
||||||
from .utilities.factory import addrole_embed, case_factory, changes_factory, evidenceformat_factory, guild_embed, immune_embed, overrides_embed, type_embed
|
from .utilities.factory import addrole_embed, case_factory, changes_factory, evidenceformat_factory, guild_embed, immune_embed, overrides_embed, type_embed
|
||||||
from .utilities.json import dump
|
from .utilities.json import dump
|
||||||
from .utilities.logger import logger
|
from .utilities.logger import logger
|
||||||
from .utilities.utils import check_moddable, check_permissions, create_guild_table, log
|
from .utilities.utils import check_moddable, check_permissions, create_guild_table, log, timedelta_from_relativedelta
|
||||||
|
|
||||||
|
|
||||||
class Aurora(commands.Cog):
|
class Aurora(commands.Cog):
|
||||||
|
@ -1002,7 +1002,7 @@ class Aurora(commands.Cog):
|
||||||
self,
|
self,
|
||||||
interaction: discord.Interaction,
|
interaction: discord.Interaction,
|
||||||
case: int,
|
case: int,
|
||||||
reason: str,
|
reason: str | None = None,
|
||||||
duration: str | None = None,
|
duration: str | None = None,
|
||||||
):
|
):
|
||||||
"""Edit the reason of a specific case.
|
"""Edit the reason of a specific case.
|
||||||
|
@ -1046,8 +1046,12 @@ class Aurora(commands.Cog):
|
||||||
)
|
)
|
||||||
|
|
||||||
if duration:
|
if duration:
|
||||||
moderation.duration = parse_timedelta(duration)
|
try:
|
||||||
if moderation.duration is None:
|
parsed_time = parse_relativedelta(argument=duration)
|
||||||
|
if parsed_time is None:
|
||||||
|
raise commands.BadArgument()
|
||||||
|
parsed_time = timedelta_from_relativedelta(relativedelta=parsed_time)
|
||||||
|
except (commands.BadArgument, ValueError):
|
||||||
return await interaction.response.send_message(
|
return await interaction.response.send_message(
|
||||||
error("Please provide a valid duration!"), ephemeral=True
|
error("Please provide a valid duration!"), ephemeral=True
|
||||||
)
|
)
|
||||||
|
@ -1066,6 +1070,11 @@ class Aurora(commands.Cog):
|
||||||
if reason:
|
if reason:
|
||||||
moderation.reason = reason
|
moderation.reason = reason
|
||||||
|
|
||||||
|
if not reason and not duration:
|
||||||
|
return await interaction.response.send_message(
|
||||||
|
error("Please provide a new reason or duration to edit this case!"), ephemeral=True
|
||||||
|
)
|
||||||
|
|
||||||
if not moderation.changes:
|
if not moderation.changes:
|
||||||
moderation.changes.append(Change.from_dict(interaction.client, {
|
moderation.changes.append(Change.from_dict(interaction.client, {
|
||||||
"type": "ORIGINAL",
|
"type": "ORIGINAL",
|
||||||
|
@ -1075,20 +1084,10 @@ class Aurora(commands.Cog):
|
||||||
"duration": old_moderation.duration,
|
"duration": old_moderation.duration,
|
||||||
"end_timestamp": old_moderation.end_timestamp,
|
"end_timestamp": old_moderation.end_timestamp,
|
||||||
}))
|
}))
|
||||||
if duration:
|
|
||||||
moderation.changes.append(Change.from_dict(interaction.client, {
|
moderation.changes.append(Change.from_dict(interaction.client, {
|
||||||
"type": "EDIT",
|
"type": "EDIT",
|
||||||
"timestamp": int(time.time()),
|
"timestamp": int(time.time()),
|
||||||
"reason": reason,
|
"reason": moderation.reason,
|
||||||
"user_id": interaction.user.id,
|
|
||||||
"duration": moderation.duration,
|
|
||||||
"end_timestamp": moderation.end_timestamp,
|
|
||||||
}))
|
|
||||||
else:
|
|
||||||
moderation.changes.append(Change.from_dict(interaction.client, {
|
|
||||||
"type": "EDIT",
|
|
||||||
"timestamp": int(time.time()),
|
|
||||||
"reason": reason,
|
|
||||||
"user_id": interaction.user.id,
|
"user_id": interaction.user.id,
|
||||||
"duration": moderation.duration,
|
"duration": moderation.duration,
|
||||||
"end_timestamp": moderation.end_timestamp,
|
"end_timestamp": moderation.end_timestamp,
|
||||||
|
|
Loading…
Reference in a new issue