diff --git a/moderation/moderation.py b/moderation/moderation.py index 1ca2a81..18eb6a0 100644 --- a/moderation/moderation.py +++ b/moderation/moderation.py @@ -1,11 +1,13 @@ -from datetime import datetime, timedelta, timezone import logging import time +from datetime import datetime, timedelta, timezone import discord +import humanize import mysql.connector from pytimeparse2 import disable_dateutil, parse from redbot.core import Config, checks, commands + class Moderation(commands.Cog): """Custom cog moderation cog, meant to copy GalacticBot. Developed by SeaswimmerTheFsh.""" @@ -182,9 +184,9 @@ class Moderation(commands.Cog): await ctx.message.reply(f"Please provide a valid duration!\nSee `{ctx.prefix}tdc`") return await target.timeout(parsed_time) - response = await ctx.send(content=f"{target.mention} has been muted for {str(parsed_time)}!\n**Reason** - `{reason}`") + response = await ctx.send(content=f"{target.mention} has been muted for {humanize.precisedelta(parsed_time)}!\n**Reason** - `{reason}`") try: - embed = discord.Embed(title="Muted", description=f"You have been muted for `{str(parsed_time)}` in [{ctx.guild.name}]({response.jump_url}).", color=await self.bot.get_embed_color(None)) + embed = discord.Embed(title="Muted", description=f"You have been muted for `{humanize.precisedelta(parsed_time)}` in [{ctx.guild.name}]({response.jump_url}).", color=await self.bot.get_embed_color(None)) embed.add_field(name='Reason', value=f"`{reason}`") await target.send(embed=embed) except discord.errors.HTTPException: diff --git a/poetry.lock b/poetry.lock index 7a87eec..d621e76 100644 --- a/poetry.lock +++ b/poetry.lock @@ -805,6 +805,20 @@ cli = ["click (==8.*)", "pygments (==2.*)", "rich (>=10,<14)"] http2 = ["h2 (>=3,<5)"] socks = ["socksio (==1.*)"] +[[package]] +name = "humanize" +version = "4.8.0" +description = "Python humanize utilities" +optional = false +python-versions = ">=3.8" +files = [ + {file = "humanize-4.8.0-py3-none-any.whl", hash = "sha256:8bc9e2bb9315e61ec06bf690151ae35aeb65651ab091266941edf97c90836404"}, + {file = "humanize-4.8.0.tar.gz", hash = "sha256:9783373bf1eec713a770ecaa7c2d7a7902c98398009dfa3d8a2df91eec9311e8"}, +] + +[package.extras] +tests = ["freezegun", "pytest", "pytest-cov"] + [[package]] name = "idna" version = "3.4" @@ -2407,4 +2421,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = ">=3.11,<3.12" -content-hash = "08f482e464da76e9f2720b46520c5a93c8fe5c7d8ecd8c894ccc5be9416f7d30" +content-hash = "ba518ebf98dfa9fbbbc3c9acbbde5916796d7aafde79d455e13eb5ef46089717" diff --git a/pyproject.toml b/pyproject.toml index 60e39db..252f20e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -13,6 +13,7 @@ pytimeparse2 = "^1.7.1" yt-dlp = "^2023.9.24" prisma = "^0.10.0" mysql-connector-python = "^8.1.0" +humanize = "^4.8.0" [tool.poetry.group.dev] optional = true