diff options
Diffstat (limited to '')
| -rw-r--r-- | bot/exts/help_channels/_message.py | 6 | ||||
| -rw-r--r-- | bot/utils/messages.py | 9 | 
2 files changed, 4 insertions, 11 deletions
| diff --git a/bot/exts/help_channels/_message.py b/bot/exts/help_channels/_message.py index 95aca067a..4113e51c5 100644 --- a/bot/exts/help_channels/_message.py +++ b/bot/exts/help_channels/_message.py @@ -1,4 +1,5 @@  import logging +import textwrap  import typing as t  from datetime import datetime @@ -8,7 +9,6 @@ import bot  from bot import constants  from bot.exts.help_channels import _caches  from bot.utils.channel import is_in_category -from bot.utils.messages import truncate_message  log = logging.getLogger(__name__) @@ -108,7 +108,9 @@ async def dm_on_open(message: discord.Message) -> None:      embed.set_thumbnail(url=constants.Icons.green_questionmark)      embed.add_field( -        name="Your message", value=truncate_message(message, limit=100), inline=False +        name="Your message", +        value=textwrap.shorten(message.content, width=100, placeholder="..."), +        inline=False,      )      embed.add_field(          name="Conversation", diff --git a/bot/utils/messages.py b/bot/utils/messages.py index c01fa5d0e..077dd9569 100644 --- a/bot/utils/messages.py +++ b/bot/utils/messages.py @@ -154,12 +154,3 @@ async def send_denial(ctx: Context, reason: str) -> None:  def format_user(user: discord.abc.User) -> str:      """Return a string for `user` which has their mention and ID."""      return f"{user.mention} (`{user.id}`)" - - -def truncate_message(message: discord.Message, limit: int) -> str: -    """Returns a truncated version of the message content, up to the specified limit.""" -    text = message.content -    if len(text) > limit: -        return text[:limit-3] + "..." -    else: -        return text | 
