Reducing spam for member_update

pull/9/head
sgoudham 4 years ago
parent 376dfe4a37
commit 027010e903

@ -562,8 +562,8 @@ class Moderation(Cog):
if modlogs := self.bot.get_modlog_for_guild(after.guild.id): if modlogs := self.bot.get_modlog_for_guild(after.guild.id):
modlogs_channel = self.bot.get_channel(modlogs) modlogs_channel = self.bot.get_channel(modlogs)
# Logging Nickname Updates # Logging Member Updates when nickname changes
if before.nick != after.nick or before.status != after.status or before.activity != after.activity and not before.bot: if before.nick != after.nick and not after.bot:
# Getting emoji of status from dict # Getting emoji of status from dict
for key, value in member_status.items(): for key, value in member_status.items():
@ -573,13 +573,12 @@ class Moderation(Cog):
after_status = value after_status = value
# Getting status of the member # Getting status of the member
before_activity = f"{before.activity.emoji or '' if before.activity.type.name == 'custom' else ''} {before.activity.name}" if before.activity else "None"
after_activity = f"{after.activity.emoji or '' if after.activity.type.name == 'custom' else ''} {after.activity.name}" if after.activity else "None" after_activity = f"{after.activity.emoji or '' if after.activity.type.name == 'custom' else ''} {after.activity.name}" if after.activity else "None"
fields = [("Before", fields = [("Before",
f"**Nickname -->** {before.nick or 'None'}\n" f"**Nickname -->** {before.nick or 'None'}\n"
f"**Status -->** {before_status or 'None'}\n" f"**Status -->** {before_status or 'None'}\n"
f"**Activity -->** {before_activity}\n", False), f"**Activity -->** {after_activity}\n", False),
("After", ("After",
f"**Nickname -->** {after.nick or 'None'}\n" f"**Nickname -->** {after.nick or 'None'}\n"
f"**Status -->** {after_status or 'None'}\n" f"**Status -->** {after_status or 'None'}\n"
@ -846,7 +845,7 @@ class Moderation(Cog):
@Cog.listener() @Cog.listener()
async def on_guild_channel_update(self, before, after): async def on_guild_channel_update(self, before, after):
"""Logging channel updates""" """Logging guild channel updates"""
if modlogs := self.bot.get_modlog_for_guild(after.guild.id): if modlogs := self.bot.get_modlog_for_guild(after.guild.id):
modlogs_channel = self.bot.get_channel(modlogs) modlogs_channel = self.bot.get_channel(modlogs)
@ -902,12 +901,24 @@ class Moderation(Cog):
value=role_string(old_roles) or after.guild.default_role.mention, inline=False) value=role_string(old_roles) or after.guild.default_role.mention, inline=False)
embed.add_field(name="After", embed.add_field(name="After",
value=role_string(new_roles) or after.guild.default_role.mention, inline=False) value=role_string(new_roles) or after.guild.default_role.mention, inline=False)
embed.set_footer(text=f"ID: {after.id}") embed.set_footer(text="Role Overrides Updated")
await modlogs_channel.send(embed=embed) await modlogs_channel.send(embed=embed)
# TODO: REMEMBER TO TRY AND LOG CHANNEL OVERWRITES # TODO: REMEMBER TO TRY AND LOG CHANNEL OVERWRITES
@Cog.listener()
async def on_guild_update(self, before, after):
"""Logging guild updates"""
if modlogs := self.bot.get_modlog_for_guild(after.guild.id):
modlogs_channel = self.bot.get_channel(modlogs)
# Logging Channel Name/Category/Position Updates
if before.name != after.name or before.verification_level != after.verification_level \
or before.afk_channel != after.afk.channel:
pass
def setup(bot): def setup(bot):
bot.add_cog(Moderation(bot)) bot.add_cog(Moderation(bot))

Loading…
Cancel
Save