fix(aurora): fixed JSON serializing error in /edit
command
This commit is contained in:
parent
566608de24
commit
e1cc6ca1a8
3 changed files with 13 additions and 8 deletions
|
@ -25,7 +25,7 @@ from .utilities.config import config, register_config
|
|||
from .utilities.database import connect, create_guild_table, fetch_case, mysql_log
|
||||
from .utilities.embed_factory import embed_factory
|
||||
from .utilities.logger import logger
|
||||
from .utilities.utils import check_moddable, check_permissions, fetch_channel_dict, fetch_user_dict, generate_dict, log, send_evidenceformat
|
||||
from .utilities.utils import convert_timedelta_to_str, check_moddable, check_permissions, fetch_channel_dict, fetch_user_dict, generate_dict, log, send_evidenceformat
|
||||
|
||||
|
||||
class Aurora(commands.Cog):
|
||||
|
@ -898,7 +898,7 @@ class Aurora(commands.Cog):
|
|||
'timestamp': int(time.time()),
|
||||
'reason': reason,
|
||||
'user_id': interaction.user.id,
|
||||
'duration': parsed_time,
|
||||
'duration': convert_timedelta_to_str(parsed_time),
|
||||
'end_timestamp': end_timestamp
|
||||
}
|
||||
)
|
||||
|
|
|
@ -9,7 +9,7 @@ from discord import Guild
|
|||
from redbot.core import data_manager
|
||||
|
||||
from .logger import logger
|
||||
from .utils import generate_dict, get_next_case_number
|
||||
from .utils import generate_dict, get_next_case_number, convert_timedelta_to_str
|
||||
|
||||
|
||||
def connect() -> sqlite3.Connection:
|
||||
|
@ -128,11 +128,7 @@ async def mysql_log(
|
|||
end_timedelta = datetime.fromtimestamp(timestamp) + duration
|
||||
end_timestamp = int(end_timedelta.timestamp())
|
||||
|
||||
total_seconds = int(duration.total_seconds())
|
||||
hours = total_seconds // 3600
|
||||
minutes = (total_seconds % 3600) // 60
|
||||
seconds = total_seconds % 60
|
||||
duration = f"{hours}:{minutes}:{seconds}"
|
||||
duration = convert_timedelta_to_str(duration)
|
||||
else:
|
||||
end_timestamp = 0
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# pylint: disable=cyclic-import
|
||||
|
||||
import json
|
||||
from datetime import timedelta as td
|
||||
from typing import Union
|
||||
|
||||
from discord import Guild, Interaction, Member, User
|
||||
|
@ -221,3 +222,11 @@ async def send_evidenceformat(interaction: Interaction, case_dict: dict):
|
|||
"evidenceformat", await interaction.client.get_embed_color(None), interaction=interaction, case_dict=case_dict
|
||||
)
|
||||
await interaction.followup.send(content=content, ephemeral=True)
|
||||
|
||||
def convert_timedelta_to_str(timedelta: td):
|
||||
"""This function converts a timedelta object to a string."""
|
||||
total_seconds = int(timedelta.total_seconds())
|
||||
hours = total_seconds // 3600
|
||||
minutes = (total_seconds % 3600) // 60
|
||||
seconds = total_seconds % 60
|
||||
return f"{hours}:{minutes}:{seconds}"
|
||||
|
|
Loading…
Reference in a new issue