Repository: python-discord/bot

Issue:
Seperate out moderation logs from user logs in #mod-logs
**Originally posted by Thomas Petersson:**

Might be handy to be able to have them separate if we ever need to review moderation based events like a kick / ban.

Thoughts?


Discussion:
**Comment from Johannes Christ:**

I agree. Maybe we should put user logs (such as username updates) in #message-change-logs and name it something like `#general-log` and keep moderation events in `#mod-logs`?
Any more thoughts on this? Related discussions have been popping up occasionally as we've been adding logging embeds to other functions. Perhaps a broader look at everything currently logged is in order?
yeah I totally think we should do this. it's not a lot of work, one extra channel, and makes it much easier to keep up with the important stuff. I'd mute general logs, but keep up with infraction logs. It'd be super useful.

This should be fairly trivial for an admin to handle, and I'd personally very much like to see it sooner rather than later.
To keep everyone on the same page, here's what I'm seeing as the proposed layout

- \#message-change-logs
  - Leave as-is
- \#mod-log
  - Infraction logs (including shadow versions, where applicable)
    - Mute, Kick (includes DEFCON), Ban, Warn ~~(not yet implemented, proposed in #137)~~
- \#user-log
  - Title TBD (suggestions?)
  - General user logs
    - Join, part, update

Anything missing?
That looks solid. Warns are implemented too now. I think `#user-log` is a good name.
#user-log has been created, ID `528976905546760203`
I'm in the process of doing some code tidying and consolidation in the moderation cog. Since this is within the scope of refinement, I'll happily take this on as part of the same PR, as it won't take much to add. 

Resolving patch:
diff --git a/bot/cogs/events.py b/bot/cogs/events.py
--- a/bot/cogs/events.py
+++ b/bot/cogs/events.py
@@ -1,4 +1,5 @@
 import logging
+from functools import partial
 
 from discord import Colour, Embed, Member, Object
 from discord.ext.commands import (
@@ -7,7 +8,6 @@
     Context, NoPrivateMessage, UserInputError
 )
 
-from bot.cogs.modlog import ModLog
 from bot.constants import (
     Channels, Colours, DEBUG_MODE,
     Guild, Icons, Keys,
@@ -28,8 +28,9 @@ def __init__(self, bot: Bot):
         self.headers = {"X-API-KEY": Keys.site_api}
 
     @property
-    def mod_log(self) -> ModLog:
-        return self.bot.get_cog("ModLog")
+    def send_log(self) -> partial:
+        cog = self.bot.get_cog("ModLog")
+        return partial(cog.send_log_message, channel_id=Channels.userlog)
 
     async def send_updated_users(self, *users, replace_all=False):
         users = list(filter(lambda user: str(Roles.verified) in user["roles"], users))
@@ -249,7 +250,7 @@ async def on_member_join(self, member: Member):
         except Exception as e:
             log.exception("Failed to persist roles")
 
-            await self.mod_log.send_log_message(
+            await self.send_log(
                 Icons.crown_red, Colour(Colours.soft_red), "Failed to persist roles",
                 f"```py\n{e}\n```",
                 member.avatar_url_as(static_format="png")
@@ -290,7 +291,7 @@ async def on_member_join(self, member: Member):
                 reason="Roles restored"
             )
 
-            await self.mod_log.send_log_message(
+            await self.send_log(
                 Icons.crown_blurple, Colour.blurple(), "Roles restored",
                 f"Restored {len(new_roles)} roles",
                 member.avatar_url_as(static_format="png")
diff --git a/bot/cogs/modlog.py b/bot/cogs/modlog.py
--- a/bot/cogs/modlog.py
+++ b/bot/cogs/modlog.py
@@ -381,7 +381,8 @@ async def on_member_ban(self, guild: Guild, member: Union[Member, User]):
         await self.send_log_message(
             Icons.user_ban, Colour(Colours.soft_red),
             "User banned", f"{member.name}#{member.discriminator} (`{member.id}`)",
-            thumbnail=member.avatar_url_as(static_format="png")
+            thumbnail=member.avatar_url_as(static_format="png"),
+            channel_id=Channels.modlog
         )
 
     async def on_member_join(self, member: Member):
@@ -400,7 +401,8 @@ async def on_member_join(self, member: Member):
         await self.send_log_message(
             Icons.sign_in, Colour(Colours.soft_green),
             "User joined", message,
-            thumbnail=member.avatar_url_as(static_format="png")
+            thumbnail=member.avatar_url_as(static_format="png"),
+            channel_id=Channels.userlog
         )
 
     async def on_member_remove(self, member: Member):
@@ -414,7 +416,8 @@ async def on_member_remove(self, member: Member):
         await self.send_log_message(
             Icons.sign_out, Colour(Colours.soft_red),
             "User left", f"{member.name}#{member.discriminator} (`{member.id}`)",
-            thumbnail=member.avatar_url_as(static_format="png")
+            thumbnail=member.avatar_url_as(static_format="png"),
+            channel_id=Channels.userlog
         )
 
     async def on_member_unban(self, guild: Guild, member: User):
@@ -428,7 +431,8 @@ async def on_member_unban(self, guild: Guild, member: User):
         await self.send_log_message(
             Icons.user_unban, Colour.blurple(),
             "User unbanned", f"{member.name}#{member.discriminator} (`{member.id}`)",
-            thumbnail=member.avatar_url_as(static_format="png")
+            thumbnail=member.avatar_url_as(static_format="png"),
+            channel_id=Channels.modlog
         )
 
     async def on_member_update(self, before: Member, after: Member):
@@ -516,7 +520,8 @@ async def on_member_update(self, before: Member, after: Member):
         await self.send_log_message(
             Icons.user_update, Colour.blurple(),
             "Member updated", message,
-            thumbnail=after.avatar_url_as(static_format="png")
+            thumbnail=after.avatar_url_as(static_format="png"),
+            channel_id=Channels.userlog
         )
 
     async def on_raw_bulk_message_delete(self, event: RawBulkMessageDeleteEvent):
diff --git a/bot/constants.py b/bot/constants.py
--- a/bot/constants.py
+++ b/bot/constants.py
@@ -352,6 +352,7 @@ class Channels(metaclass=YAMLGetter):
     off_topic_3: int
     python: int
     reddit: int
+    userlog: int
     verification: int
 
 


Test patch: