aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-07-20 10:31:41 -0700
committerGravatar MarkKoz <[email protected]>2020-07-21 10:30:24 -0700
commitd35c603c8fb252335d58451d2310fd2b55585e22 (patch)
tree11c17a3c2ba993220e94ecf9a2908e1fb69de724
parentClean up imports (diff)
Add util function to format user names
This will be used a lot when sending mod logs and will help with reducing redundancy and maintaining consistency.
Diffstat (limited to '')
-rw-r--r--bot/utils/messages.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/bot/utils/messages.py b/bot/utils/messages.py
index 63bda877c..31825d4a7 100644
--- a/bot/utils/messages.py
+++ b/bot/utils/messages.py
@@ -9,6 +9,7 @@ from typing import List, Optional, Sequence, Union
import discord
from discord.errors import HTTPException
from discord.ext.commands import Context
+from discord.utils import escape_markdown
from bot.constants import Emojis, NEGATIVE_REPLIES
@@ -143,3 +144,9 @@ async def send_denial(ctx: Context, reason: str) -> None:
embed.description = reason
await ctx.send(embed=embed)
+
+
+def format_user(user: discord.abc.User) -> str:
+ """Return a string for `user` which has their mention and name#discriminator."""
+ name = escape_markdown(str(user))
+ return f"{user.mention} ({name})"