fix(aurora): fixed JSON serializing error in /edit command
Some checks failed
Pylint / Pylint (3.11) (push) Failing after 40s

This commit is contained in:
SeaswimmerTheFsh 2023-12-30 04:10:25 -05:00
parent 566608de24
commit e1cc6ca1a8
Signed by: cswimr
GPG key ID: 1EBC234EEDA901AE
3 changed files with 13 additions and 8 deletions

View file

@ -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

View file

@ -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}"