import discord.commands from discord.ext import commands import datetime class Moderation(commands.Cog, name="Moderation"): def __init__(self, bot): self.bot = bot @commands.Cog.listener() async def on_member_join(self, member): guild = member.guild if guild.system_channel is not None: embed = discord.Embed(color=discord.Color.green(), description=f"{member.mention} | **Joined Discord**: {member.created_at.date()}", timestamp=datetime.datetime.now()) embed.set_author(name=f"{member} ({member.id})", icon_url=f"{member.display_avatar.url}?128") embed.set_footer(text="User Left") await guild.system_channel.send(embeds=[embed]) @commands.Cog.listener() async def on_member_remove(self, member): guild = member.guild if guild.system_channel is not None: embed = discord.Embed(color=discord.Color.red(), description=f"{member.mention} | **Joined Server**: {member.joined_at.date()}", timestamp=datetime.datetime.now()) embed.set_author(name=f"{member} ({member.id})", icon_url=f"{member.display_avatar.url}?128") embed.set_footer(text="User Left") await guild.system_channel.send(embeds=[embed]) def setup(bot): bot.add_cog(Moderation(bot))