aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-07-20 14:44:04 -0700
committerGravatar MarkKoz <[email protected]>2020-07-21 10:30:31 -0700
commitb5dce5b6d5ee096a3fd4daec0e72405159aee87d (patch)
tree605a0dc0b4e0478769b3469d31d7c8748ea27854
parentModeration: remove multiple active infractions check (diff)
Moderation: use user mentions in mod logs
-rw-r--r--bot/cogs/moderation/infractions.py3
-rw-r--r--bot/cogs/moderation/management.py14
-rw-r--r--bot/cogs/moderation/scheduler.py15
3 files changed, 14 insertions, 18 deletions
diff --git a/bot/cogs/moderation/infractions.py b/bot/cogs/moderation/infractions.py
index 8df642428..5404991e8 100644
--- a/bot/cogs/moderation/infractions.py
+++ b/bot/cogs/moderation/infractions.py
@@ -13,6 +13,7 @@ from bot.constants import Event
from bot.converters import Expiry, FetchedMember
from bot.decorators import respect_role_hierarchy
from bot.utils.checks import with_role_check
+from bot.utils.messages import format_user
from . import utils
from .scheduler import InfractionScheduler
from .utils import UserSnowflake
@@ -316,7 +317,7 @@ class Infractions(InfractionScheduler, commands.Cog):
icon_url=utils.INFRACTION_ICONS["mute"][1]
)
- log_text["Member"] = f"{user.mention}(`{user.id}`)"
+ log_text["Member"] = format_user(user)
log_text["DM"] = "Sent" if notified else "**Failed**"
else:
log.info(f"Failed to unmute user {user_id}: user not found")
diff --git a/bot/cogs/moderation/management.py b/bot/cogs/moderation/management.py
index 672bb0e9c..e0a86ee59 100644
--- a/bot/cogs/moderation/management.py
+++ b/bot/cogs/moderation/management.py
@@ -11,7 +11,7 @@ from bot import constants
from bot.bot import Bot
from bot.converters import Expiry, InfractionSearchQuery, allowed_strings, proxy_user
from bot.pagination import LinePaginator
-from bot.utils import time
+from bot.utils import messages, time
from bot.utils.checks import in_whitelist_check, with_role_check
from . import utils
from .infractions import Infractions
@@ -154,16 +154,12 @@ class ModManagement(commands.Cog):
user = ctx.guild.get_member(user_id)
if user:
- user_text = f"{user.mention} (`{user.id}`)"
+ user_text = messages.format_user(user)
thumbnail = user.avatar_url_as(static_format="png")
else:
- user_text = f"`{user_id}`"
+ user_text = f"<@{user_id}>"
thumbnail = None
- # The infraction's actor
- actor_id = new_infraction['actor']
- actor = ctx.guild.get_member(actor_id) or f"`{actor_id}`"
-
await self.mod_log.send_log_message(
icon_url=constants.Icons.pencil,
colour=discord.Colour.blurple(),
@@ -171,8 +167,8 @@ class ModManagement(commands.Cog):
thumbnail=thumbnail,
text=textwrap.dedent(f"""
Member: {user_text}
- Actor: {actor}
- Edited by: {ctx.message.author}{log_text}
+ Actor: <@{new_infraction['actor']}>
+ Edited by: {ctx.message.author.mention}{log_text}
""")
)
diff --git a/bot/cogs/moderation/scheduler.py b/bot/cogs/moderation/scheduler.py
index 0b0bc9eb7..6323bd55a 100644
--- a/bot/cogs/moderation/scheduler.py
+++ b/bot/cogs/moderation/scheduler.py
@@ -13,8 +13,7 @@ from bot import constants
from bot.api import ResponseCodeError
from bot.bot import Bot
from bot.constants import Colours, STAFF_CHANNELS
-from bot.utils import time
-from bot.utils.scheduling import Scheduler
+from bot.utils import messages, scheduling, time
from . import utils
from .modlog import ModLog
from .utils import UserSnowflake
@@ -27,7 +26,7 @@ class InfractionScheduler:
def __init__(self, bot: Bot, supported_infractions: t.Container[str]):
self.bot = bot
- self.scheduler = Scheduler(self.__class__.__name__)
+ self.scheduler = scheduling.Scheduler(self.__class__.__name__)
self.bot.loop.create_task(self.reschedule_infractions(supported_infractions))
@@ -193,8 +192,8 @@ class InfractionScheduler:
title=f"Infraction {log_title}: {infr_type}",
thumbnail=user.avatar_url_as(static_format="png"),
text=textwrap.dedent(f"""
- Member: {user.mention} (`{user.id}`)
- Actor: {ctx.message.author}{dm_log_text}{expiry_log_text}
+ Member: {messages.format_user(user)}
+ Actor: {ctx.message.author.mention}{dm_log_text}{expiry_log_text}
Reason: {reason}
"""),
content=log_content,
@@ -237,8 +236,8 @@ class InfractionScheduler:
# Deactivate the infraction and cancel its scheduled expiration task.
log_text = await self.deactivate_infraction(response[0], send_log=False)
- log_text["Member"] = f"{user.mention}(`{user.id}`)"
- log_text["Actor"] = str(ctx.message.author)
+ log_text["Member"] = messages.format_user(user)
+ log_text["Actor"] = ctx.message.author.mention
log_content = None
id_ = response[0]['id']
footer = f"ID: {id_}"
@@ -316,7 +315,7 @@ class InfractionScheduler:
log_content = None
log_text = {
"Member": f"<@{user_id}>",
- "Actor": str(self.bot.get_user(actor) or actor),
+ "Actor": f"<@{actor}>",
"Reason": infraction["reason"],
"Created": created,
}