mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
Modlog account for very long case reasons (#4541)
* Modlog account for very long case reasons * if
This commit is contained in:
parent
b30a8b86a4
commit
085cd1bb49
@ -15,6 +15,7 @@ from .utils.common_filters import (
|
||||
filter_urls,
|
||||
escape_spoilers,
|
||||
)
|
||||
from .utils.chat_formatting import pagify
|
||||
from .i18n import Translator, set_contextual_locales_from_guild
|
||||
|
||||
from .generic_casetypes import all_generics
|
||||
@ -342,11 +343,7 @@ class Case:
|
||||
title = "{}".format(
|
||||
_("Case #{} | {} {}").format(self.case_number, casetype.case_str, casetype.image)
|
||||
)
|
||||
|
||||
if self.reason:
|
||||
reason = _("**Reason:** {}").format(self.reason)
|
||||
else:
|
||||
reason = _("**Reason:** Use the `reason` command to add it")
|
||||
reason = _("**Reason:** Use the `reason` command to add it")
|
||||
|
||||
if self.moderator is None:
|
||||
moderator = _("Unknown")
|
||||
@ -403,6 +400,19 @@ class Case:
|
||||
) # Invites and spoilers get rendered even in embeds.
|
||||
|
||||
if embed:
|
||||
if self.reason:
|
||||
reason = _("**Reason:** {}").format(self.reason)
|
||||
if len(reason) > 2048:
|
||||
reason = (
|
||||
next(
|
||||
pagify(
|
||||
reason,
|
||||
delims=[" ", "\n"],
|
||||
page_length=2000,
|
||||
)
|
||||
)
|
||||
+ "..."
|
||||
)
|
||||
emb = discord.Embed(title=title, description=reason)
|
||||
emb.set_author(name=user)
|
||||
emb.add_field(name=_("Moderator"), value=moderator, inline=False)
|
||||
@ -425,6 +435,19 @@ class Case:
|
||||
emb.timestamp = datetime.utcfromtimestamp(self.created_at)
|
||||
return emb
|
||||
else:
|
||||
if self.reason:
|
||||
reason = _("**Reason:** {}").format(self.reason)
|
||||
if len(reason) > 1000:
|
||||
reason = (
|
||||
next(
|
||||
pagify(
|
||||
reason,
|
||||
delims=[" ", "\n"],
|
||||
page_length=1000,
|
||||
)
|
||||
)
|
||||
+ "..."
|
||||
)
|
||||
user = filter_mass_mentions(filter_urls(user)) # Further sanitization outside embeds
|
||||
case_text = ""
|
||||
case_text += "{}\n".format(title)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user