Added logging for any emoji additions/removals

pull/9/head
sgoudham 4 years ago
parent 4841d63f04
commit f5debd5430

@ -1023,59 +1023,39 @@ class Moderation(Cog):
old_emojis = [emojis for emojis in before if emojis not in after] old_emojis = [emojis for emojis in before if emojis not in after]
# Assuming that only one emoji is returned all the time # Assuming that only one emoji is returned all the time
new_emojis_string = str(new_emojis[0]) new_emojis_string = str(new_emojis[0]) if new_emojis else None
old_emojis_string = str(old_emojis[0]) old_emojis_string = str(old_emojis[0]) if old_emojis else None
# Determining whether emoji was added or removed
if len(new_emojis) == 1: if len(new_emojis) == 1:
field = ("") field = ("Emoji Added", new_emojis_string, False)
emoji_id = new_emojis[0].id
# As long as roles were added to the Member, log the role(s) that were given animated = self.bot.tick if new_emojis[0].animated else self.bot.cross
if len(new_emojis) >= 1: managed = self.bot.tick if new_emojis[0].managed else self.bot.cross
new_roles_string = " **|** ".join(str(r) for r in new_emojis) url = new_emojis[0].url
if len(old_emojis) == 1:
# Change the description of the embed depending on how many roles were added field = ("Emoji Removed", old_emojis_string, False)
if len(new_emojis) == 1: emoji_id = old_emojis[0].id
field = ("Role Added", new_roles_string, False) animated = self.bot.tick if old_emojis[0].animated else self.bot.cross
footer = "Role Added" managed = self.bot.tick if old_emojis[0].managed else self.bot.cross
else: url = old_emojis[0].url
field = ("Roles Added", new_roles_string, False)
footer = "Roles Added" # Get total emojis
emojis = string_list(after, 50, "Emoji")
embed = Embed(title=footer, embed = Embed(title=field[0],
description=f"**Member --> {after.mention} |** {after}" description=f"**ID -->** {emoji_id}"
f"\n**ID -->** {after.id}", f"\n**Animated? -->** {animated}"
colour=self.bot.admin_colour, f"\n**Managed? -->** {managed}",
timestamp=datetime.datetime.utcnow()) colour=self.bot.admin_colour,
embed.set_author(name=after, icon_url=after.avatar_url) url=str(url),
embed.add_field(name=field[0], value=field[1], inline=field[2]) timestamp=datetime.datetime.utcnow())
embed.add_field(name="All Roles", value=role or "No Roles", inline=False) embed.set_author(name=guild, icon_url=guild.icon_url)
embed.set_footer(text=footer) embed.add_field(name=field[0], value=field[1], inline=field[2])
embed.add_field(name="All Emojis", value=emojis or "No Emojis", inline=False)
await modlogs_channel.send(embed=embed) embed.set_thumbnail(url=str(url))
embed.set_footer(text=field[0])
# As long as roles were removed from the member, log the role(s) that were removed
if len(old_roles) >= 1:
old_roles_string = " **|** ".join(r.mention for r in old_roles)
# Change the description of the embed depending on how many roles were removed
if len(old_roles) == 1:
field = ("Role Removed", old_roles_string, False)
footer = "Role Removed"
else:
field = ("Roles Removed", old_roles_string, False)
footer = "Roles Removed"
embed = Embed(title=footer,
description=f"**Member --> {after.mention} |** {after}"
f"\n**ID -->** {after.id}",
colour=self.bot.admin_colour,
timestamp=datetime.datetime.utcnow())
embed.set_author(name=after, icon_url=after.avatar_url)
embed.add_field(name=field[0], value=field[1], inline=field[2])
embed.add_field(name="All Roles", value=role or "No Roles", inline=False)
embed.set_footer(text=footer)
await modlogs_channel.send(embed=embed) await modlogs_channel.send(embed=embed)
def setup(bot): def setup(bot):

Loading…
Cancel
Save