|
|
@ -23,7 +23,7 @@ from discord import Member, Embed, DMChannel, NotFound
|
|
|
|
from discord.ext.commands import command, guild_only, has_guild_permissions, bot_has_guild_permissions, Greedy, \
|
|
|
|
from discord.ext.commands import command, guild_only, has_guild_permissions, bot_has_guild_permissions, Greedy, \
|
|
|
|
cooldown, BucketType, Cog
|
|
|
|
cooldown, BucketType, Cog
|
|
|
|
|
|
|
|
|
|
|
|
from cogs.libs.functions import string_list, get_region
|
|
|
|
from cogs.libs.functions import string_list, get_region, get_content_filter, get_notifs
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: CREATE A BITARRAY SO THAT THE MODLOG EVENTS ARE TOGGLEABLE
|
|
|
|
# TODO: CREATE A BITARRAY SO THAT THE MODLOG EVENTS ARE TOGGLEABLE
|
|
|
|
# TODO: MAKE SURE THAT THE BITARRAY IS ONLY IMPLEMENTED AFTER ALL EVENTS ARE CODED
|
|
|
|
# TODO: MAKE SURE THAT THE BITARRAY IS ONLY IMPLEMENTED AFTER ALL EVENTS ARE CODED
|
|
|
@ -874,29 +874,21 @@ class Moderation(Cog):
|
|
|
|
new_roles = [roles for roles in after.changed_roles]
|
|
|
|
new_roles = [roles for roles in after.changed_roles]
|
|
|
|
old_roles = [roles for roles in before.changed_roles]
|
|
|
|
old_roles = [roles for roles in before.changed_roles]
|
|
|
|
|
|
|
|
|
|
|
|
def role_string(roles):
|
|
|
|
# Get total new_roles in the channel
|
|
|
|
# Check if the amount of roles is above 20
|
|
|
|
new_role_string = string_list(new_roles, 20, "Role")
|
|
|
|
if len(roles) > 20:
|
|
|
|
# Get total old_roles in the channel
|
|
|
|
# Retrieve the length of the remaining roles
|
|
|
|
old_role_string = string_list(old_roles, 20, "Role")
|
|
|
|
length = len(roles) - 20
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Store the first 20 roles in a string (highest to lowest)
|
|
|
|
embed = Embed(title="Role Overrides Updated",
|
|
|
|
string = f"{' **|** '.join(role.mention for role in list(reversed(roles))[:20])} and **{length}** more"
|
|
|
|
description=f"**Channel -->** {after.mention}\n"
|
|
|
|
return string
|
|
|
|
f"**ID -->** {after.id}",
|
|
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
# Display all roles as it is lower than 20
|
|
|
|
|
|
|
|
string = f"{' **|** '.join(role.mention for role in list(reversed(roles[1:])))}"
|
|
|
|
|
|
|
|
return string
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
embed = Embed(description=f"**{after.mention} Role Overrides Updated**",
|
|
|
|
|
|
|
|
colour=self.bot.admin_colour,
|
|
|
|
colour=self.bot.admin_colour,
|
|
|
|
timestamp=datetime.datetime.utcnow())
|
|
|
|
timestamp=datetime.datetime.utcnow())
|
|
|
|
embed.set_author(name=after.guild, icon_url=after.guild.icon_url)
|
|
|
|
embed.set_author(name=after.guild, icon_url=after.guild.icon_url)
|
|
|
|
embed.add_field(name="Before",
|
|
|
|
embed.add_field(name="Before",
|
|
|
|
value=role_string(old_roles) or after.guild.default_role.mention, inline=False)
|
|
|
|
value=old_role_string 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=new_role_string or after.guild.default_role.mention, inline=False)
|
|
|
|
embed.set_footer(text="Role Overrides Updated")
|
|
|
|
embed.set_footer(text="Role Overrides Updated")
|
|
|
|
|
|
|
|
|
|
|
|
await modlogs_channel.send(embed=embed)
|
|
|
|
await modlogs_channel.send(embed=embed)
|
|
|
@ -910,24 +902,35 @@ class Moderation(Cog):
|
|
|
|
if modlogs := self.bot.get_modlog_for_guild(after.id):
|
|
|
|
if modlogs := self.bot.get_modlog_for_guild(after.id):
|
|
|
|
modlogs_channel = self.bot.get_channel(modlogs)
|
|
|
|
modlogs_channel = self.bot.get_channel(modlogs)
|
|
|
|
|
|
|
|
|
|
|
|
# Logging guild updates
|
|
|
|
attributes = ["name", "verification_level", "afk_channel", "mfa_level", "icon_url",
|
|
|
|
if before.name != after.name or before.verification_level != after.verification_level \
|
|
|
|
"default_notifications", "region", "explicit_content_filter"]
|
|
|
|
or before.afk_channel != after.afk_channel or before.mfa_level != after.mfa_level \
|
|
|
|
|
|
|
|
or before.icon_url != after.icon_url or before.default_notifications != after.default_notifications \
|
|
|
|
if any(getattr(before, x) != getattr(after, x) for x in attributes):
|
|
|
|
or before.region != after.region:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: ADD LOGGING FOR THE ABOVE IF STATEMENTS.
|
|
|
|
# TODO: ADD LOGGING FOR THE ABOVE IF STATEMENTS.
|
|
|
|
|
|
|
|
|
|
|
|
fields = [("Before",
|
|
|
|
fields = [("Before",
|
|
|
|
f"**Guild Name -->** {before.name}\n"
|
|
|
|
f"**Guild Name -->** {before}\n"
|
|
|
|
f"**Region -->** {get_region(str(before.region))}\n"
|
|
|
|
f"**Region -->** {get_region(str(before.region))}\n\n"
|
|
|
|
f"**Verification Level -->** {before.verification_level.name.capitalize()}\n"
|
|
|
|
|
|
|
|
f"**AFK Channel -->** #{before.afk_channel or 'N/A'} **|** {before.afk_timeout}s\n", False),
|
|
|
|
f"**2-Factor Authentication -->** {self.bot.tick if before.mfa_level == 1 else self.bot.cross}\n"
|
|
|
|
|
|
|
|
f"**Explicit Content Filter -->** {get_content_filter(before.explicit_content_filter.name)}\n"
|
|
|
|
|
|
|
|
f"**Verification Level -->** {before.verification_level.name.capitalize()}\n\n"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
f"**Default Notifications -->** {get_notifs(before.default_notifications)}\n"
|
|
|
|
|
|
|
|
f"**AFK Channel -->** {before.afk_channel.mention if before.afk_channel else '#N/A'} **|** {before.afk_timeout}s\n",
|
|
|
|
|
|
|
|
False),
|
|
|
|
("After",
|
|
|
|
("After",
|
|
|
|
f"**Guild Name -->** {after.name}\n"
|
|
|
|
f"**Guild Name -->** {after}\n"
|
|
|
|
f"**Region -->** {get_region(str(after.region))}\n"
|
|
|
|
f"**Region -->** {get_region(str(after.region))}\n\n"
|
|
|
|
f"**Verification Level -->** {after.verification_level.name.capitalize()}\n"
|
|
|
|
|
|
|
|
f"**AFK Channel -->** #{after.afk_channel or 'N/A'} **|** {after.afk_timeout}s\n", False)]
|
|
|
|
f"**2-Factor Authentication -->** {self.bot.tick if after.mfa_level == 1 else self.bot.cross}\n"
|
|
|
|
|
|
|
|
f"**Explicit Content Filter -->** {get_content_filter(after.explicit_content_filter.name)}\n"
|
|
|
|
|
|
|
|
f"**Verification Level -->** {after.verification_level.name.capitalize()}\n\n"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
f"**Default Notifications -->** {get_notifs(after.default_notifications)}\n"
|
|
|
|
|
|
|
|
f"**AFK Channel -->** {after.afk_channel.mention if after.afk_channel else '#N/A'} **|** {after.afk_timeout}s\n",
|
|
|
|
|
|
|
|
False)]
|
|
|
|
|
|
|
|
|
|
|
|
embed = Embed(title="Guild Updated",
|
|
|
|
embed = Embed(title="Guild Updated",
|
|
|
|
description=f"**Owner --> {after.owner.mention} |** {after.owner}\n"
|
|
|
|
description=f"**Owner --> {after.owner.mention} |** {after.owner}\n"
|
|
|
|