Various bugfixes

This commit is contained in:
Zeva Rose 2023-01-12 04:11:37 +00:00
parent 04dd11db43
commit b6031af760
3 changed files with 13 additions and 10 deletions

View file

@ -24,7 +24,7 @@ from jarvis.utils import build_embed
from jarvis.utils.cogs import ModcaseCog
from jarvis.utils.permissions import admin_or_permissions
time_pattern = re.compile(r"(\d+\.?\d+?[s|m|h|d|w]{1})\s?", re.I)
time_pattern = re.compile(r"(\d+\.?(?:\d+)?[smhdw])\s?", re.I)
class BanCog(ModcaseCog):
@ -131,7 +131,7 @@ class BanCog(ModcaseCog):
elif btype == "temp" and duration > 744:
await ctx.send("You cannot set a temp ban to > 1 month", ephemeral=True)
return
if not time_pattern.match(delete_history):
if delete_history and not time_pattern.match(delete_history):
await ctx.send("Invalid time string, please follow example: 1w 3d 7h 5m 20s", ephemeral=True)
return
if len(reason) > 100:
@ -146,11 +146,11 @@ class BanCog(ModcaseCog):
if times := time_pattern.findall(delete_history):
for t in times:
delta[units[t[-1]]] += float(t[:-1])
delete_history = int(timedelta(**delta).total_seconds)
delete_history = int(timedelta(**delta).total_seconds())
if delete_history > 604800:
await ctx.send("Delete history cannot be greater than 7 days (604800 seconds)", ephemeral=True)
return
if delete_history > 604800:
await ctx.send("Delete history cannot be greater than 7 days (604800 seconds)", ephemeral=True)
return
await ctx.defer()
@ -173,6 +173,10 @@ class BanCog(ModcaseCog):
dm=True,
)
active = True
if btype == "soft":
active = False
try:
await user.send(embed=user_embed)
except Exception:
@ -188,9 +192,6 @@ class BanCog(ModcaseCog):
if btype != "temp":
duration = None
active = True
if btype == "soft":
active = False
@slash_command(name="unban", description="Unban a user")
@slash_option(name="user", description="User to unban", opt_type=OptionTypes.STRING, required=True)

View file

@ -64,7 +64,7 @@ class RedditCog(Extension):
images = []
title = post.title
if len(title) > 256:
title = title[253] + "..."
title = title[:253] + "..."
fields = []
content = ""
og_post = None

View file

@ -60,6 +60,8 @@ class UtilCog(Extension):
await ctx.send("https://tenor.com/view/fluffy-gabriel-iglesias-you-need-jesus-thats-what-you-need-pointing-up-gif-16385108")
elif ctx.author.id == 215564028615852033:
await ctx.send("As flattered as I am, I'm not into bestiality")
elif ctx.author.id == 256110768724901889:
await ctx.send("Haven't you broken me enough already?")
else:
await ctx.send("Not at this time, thank you for offering")