async def on_guild_role_delete(self, role): print(f'{role} was deleted.') check_log_item(role.guild.id) RolesDeleteChannelID = get_log_item(role.guild.id, "RoleDelete") if RolesDeleteChannelID != 0: if role != "": channel = self.bot.get_channel(RolesDeleteChannelID) rolecreated = str(role.created_at.strftime("%b %d, %Y")) await send_embed( channel, send_option=0, author=f"{role.guild} role deleted.", author_pfp=role.guild.icon.url, color=0xff5c5c, description=f"**Role** **{role}** was deleted.", fields=[('Role', f"{role}", True), ('ID', f"{role.id}", True), ('Color', f"{role.color}", True), ('Managed', f"{role.managed}", True), ('Position', f"{role.position}", True), ('Tags', f"{role.tags}", True), ('Mentionable', f"{role.mentionable}", True), ('Permissions', f"{role.permissions}", True)], timestamp=(datetime.utcnow()), footer=f"Role deleted")
async def on_guild_role_update(self, before, after): if after.position == before.position: print(f'{after} was updated.') check_log_item(before.guild.id) RolesUpdateChannelID = get_log_item(before.guild.id, "RoleUpdated") if RolesUpdateChannelID != 0: if before != "": channel = self.bot.get_channel(RolesUpdateChannelID) await send_embed( channel, send_option=0, author=f"{before.guild} role updated.", author_pfp=before.guild.icon.url, color=0xfff959, description=f"**Role** {after.mention} was updated.", fields=[('Role', f"{after}", True), ('ID', f"{after.id}", True), ('Color', f"{after.color}", True), ('Managed', f"{after.managed}", True), ('Position', f"{after.position}", True), ('Tags', f"{after.tags}", True), ('Mentionable', f"{after.mentionable}", True), ('Permissions Wrap', f"{after.permissions}", True)], timestamp=(datetime.utcnow()), footer=f"Role updated")
async def on_user_update(self, before, after): if before.name != after.name: for g_guild in before.mutual_guilds: if g_guild.id != 0: NickChannelID = get_log_item(g_guild.id, "NickChanged") if NickChannelID != 0: if before != "": channel = self.bot.get_channel(NickChannelID) membercreated = str( before.created_at.strftime("%b %d, %Y")) await send_embed( channel, send_option=0, author=f"{before} changed username.", author_pfp=before.avatar.url, color=0xfa7a2f, description= f"**Username event for** {before.mention}", fields=[('User before', f"{before}", True), ('User now', f"**{after}**", True), ('User ID', f"{before.id}", False), ('Account Created', f"{membercreated}", True)], timestamp=(datetime.utcnow()), footer=f"Changed Username") print(f"[{before} changed username to {after}") if before.avatar != after.avatar: return
async def on_message_delete(self, message): if message.author.bot: return if isinstance(message.author, discord.member.User): print(f"Non-Member Event Detected: {message.author}") return if isinstance(message.channel, discord.channel.DMChannel): print("Direct Message Detected..") if isinstance(message.author, discord.member.Member): check_snipes(message.author.guild.id) Author = encodebase64(str(message.author)) MessageContent = encodebase64(str(message.content)) set_db_item(message.author.guild.id, "snipes", MessageContent, "Message") set_db_item(message.author.guild.id, "snipes", message.id, "MessageID") set_db_item(message.author.guild.id, "snipes", Author, "Author") set_db_item(message.author.guild.id, "snipes", message.author.avatar.url, "AuthorAvatar") set_db_item(message.author.guild.id, "snipes", datetime.utcnow(), "Timestamp") DeleteChannelID = get_log_item(message.author.guild.id, "Delete") if DeleteChannelID != 0: if message.content != "": channel = self.bot.get_channel(DeleteChannelID) MessageFormatted = message.clean_content if len(str(MessageFormatted)) > 1300: MessageFormatted = MessageFormatted[1300] await send_embed( channel, send_option=0, author=message.author, author_pfp=message.author.avatar.url, color=0xff6e6e, description= f"Message by {message.author.mention}\n**Deleted** " f"in {message.channel.mention}", fields=[('Message', f"{MessageFormatted}", True), ('Author ID', f"{message.author.id}", False), ('Message ID', f"{message.id}", True)], timestamp=(datetime.utcnow()), footer=f"Deleted") print( f'Message Deleted: Author: {message.author} Message: {message.clean_content}.' )
async def on_guild_channel_create(self, channel): check_log_item(channel.guild.id) ChanCreateID = get_log_item(channel.guild.id, "ChanMade") if ChanCreateID != 0: if channel != "": sendchannel = self.bot.get_channel(ChanCreateID) await send_embed( sendchannel, send_option=0, author=f"{channel.guild} channel created.", author_pfp=channel.guild.icon.url, color=0x976eff, description=f"**Channel** {channel.mention} was created.", fields=[('Name', f"{channel}", True), ('ID', f"{channel.id}", True)], timestamp=(datetime.utcnow()), footer=f"Channel created") print(f'{channel} created.')
async def on_invite_delete(self, invite): check_log_item(invite.guild.id) INVDeleteID = get_log_item(invite.guild.id, "Invites") if INVDeleteID != 0: if invite != "": sendchannel = self.bot.get_channel(INVDeleteID) await send_embed( sendchannel, send_option=0, author=f"{invite.guild} invite deleted.", author_pfp=invite.guild.icon.url, color=0xfc4128, description=f"**Invite** {invite.code} was deleted.", fields=[('Channel', f"{invite.channel.mention}", True), ('Invite Code', f"{invite.code}", True)], timestamp=datetime.utcnow(), footer=f"Invite deleted") print(f'invite {invite.code} created.')
async def unmute(self, ctx, user: discord.Member = None): justprefix = await get_prefix(self.bot, ctx.message) if user is None: await send_embed(ctx, send_option=0, description=f"<:Pogbot_X:850089728018874368> " f"**You must provide a user.**" f"\nTry ```{justprefix[2]}unmute User```", color=0x08d5f7) return role = discord.utils.get(user.guild.roles, name="Muted") if role is None: await send_embed(ctx, send_option=0, description=f"<:Pogbot_X:850089728018874368> " f"**No Muted role found, try running the mute command first.**", color=0x08d5f7) return if role not in user.roles: await send_embed(ctx, send_option=0, description=f"<:Pogbot_X:850089728018874368> " f"**User must be muted first.**", color=0x08d5f7) return await user.remove_roles(role) await send_embed(ctx, send_option=0, description=f"<:Check:845178458426179605> " f"**{user} has been unmuted.**", color=0x08d5f7) MutedChannelID = get_log_item(ctx.author.guild.id, "Mute") if MutedChannelID != 0: if user != "": channel = self.bot.get_channel(MutedChannelID) membercreated = str(user.created_at.strftime("%b %d, %Y")) await send_embed(channel, send_option=0, author=f"{user} was unmuted.", author_pfp=user.avatar.url, color=0x5eff89, description=f"**{user.mention}** was unmuted.", fields=[('User', f"{user}", True), ('ID', f"{user.id}", True), ('Unmuted by', f"{ctx.message.author}", False), ('Account Created', f"{membercreated}", True)], timestamp=(datetime.utcnow()), footer=f"Unmute")
async def on_message_edit(self, before, after): if before.author.bot: return if before.clean_content != after.clean_content: if isinstance(before.author, discord.member.User): print(f"Non-Member Event Detected: {before.author}") return if isinstance(before.channel, discord.channel.DMChannel): print("Direct Message Detected..") if isinstance(before.author, discord.member.Member): EditChannelID = get_log_item(before.author.guild.id, "Edit") if EditChannelID != 0: if before.content != "": channel = self.bot.get_channel(EditChannelID) msgbefore = before.clean_content msgafter = after.clean_content if len(str(msgbefore)) > 450: msgbefore = f"**Truncated**:{before.clean_content[0:450]}..." if len(str(msgafter)) > 450: msgafter = f"**Truncated**:{after.clean_content[0:450]}..." await send_embed( channel, send_option=0, author=before.author, author_pfp=before.author.avatar.url, color=0xfff56e, description= f"Message by {before.author.mention}\n**Edited** " f"in {before.channel.mention} [Jump to message]({after.jump_url})", fields=[('Before', f"{msgbefore}", True), ('After', f"{msgafter}", True), ('Author ID', f"{after.author.id}", False), ('Message ID', f"{after.id}", True)], timestamp=after.edited_at, footer=f"Edited") print( f'Message Edited: Author: {before.author} Original: {before.clean_content} New: {after.clean_content}.' )
async def on_member_unban(self, guild, member): check_log_item(guild.id) BanChannelID = get_log_item(guild.id, "Unban") if BanChannelID != 0: if member != "": channel = self.bot.get_channel(BanChannelID) membercreated = str(member.created_at.strftime("%b %d, %Y")) await send_embed(channel, send_option=0, author=f"{member} was unbanned.", author_pfp=member.avatar.url, color=0xFFFFFF, description=f"{member.mention} was unbanned.", fields=[('User', f"{member}", True), ('User ID', f"{member.id}", True), ('Account Created', f"{membercreated}", True)], timestamp=(datetime.utcnow()), footer=f"Unban") print(f'{member} unbanned.')
async def purge(self, ctx, amount: int): embedpurge = discord.Embed(description=f'<:Check:845178458426179605> **Purged {amount} messages...**', color=0x08d5f7) await ctx.channel.purge(limit=amount + 1) purgemsg = await ctx.send(embed=embedpurge) await purgemsg.delete() DeleteChannelID = get_log_item(ctx.author.guild.id, "BulkDelete") if DeleteChannelID != 0: channel = self.bot.get_channel(DeleteChannelID) await send_embed(channel, send_option=0, author=ctx.author, author_pfp=ctx.author.avatar.url, color=0xff6e6e, description=f"{ctx.author.mention} **purged {amount} messages** " f"in {ctx.channel.mention}", fields=[('Messages Purged', f"{amount}", True), ('User ', f"{ctx.author}", False), ('User ID', f"{ctx.author.id}", False), ('Channel', f"{ctx.channel}", True), ('Channel ID', f"{ctx.channel.id}", True)], timestamp=(datetime.utcnow()), footer=f"Purge")
async def on_invite_create(self, invite): check_log_item(invite.guild.id) INVCreateID = get_log_item(invite.guild.id, "Invites") if INVCreateID != 0: if invite != "": sendchannel = self.bot.get_channel(INVCreateID) await send_embed( sendchannel, send_option=0, author=f"{invite.guild} invite created.", author_pfp=invite.guild.icon.url, color=0xf5f547, description=f"**Invite** {invite.code} was created.", fields=[('Created by', f"{invite.inviter}", True), ('Max Uses', f"{invite.max_uses}", True), ('Channel', f"{invite.channel.mention}", True), ('Max Age', f"{invite.max_age}", True), ('Temporary', f"{invite.temporary}", True), ('Invite Code', f"{invite.code}", True)], timestamp=invite.created_at, footer=f"Invite created") print(f'invite {invite.code} created.')
async def on_member_ban(self, guild, member): check_log_item(guild.id) BanChannelID = get_log_item(guild.id, "Ban") if BanChannelID != 0: if member != "": channel = self.bot.get_channel(BanChannelID) membercreated = str(member.created_at.strftime("%b %d, %Y")) banevent = await guild.audit_logs().find(banpredicate) await send_embed(channel, send_option=0, author=f"{member} was banned.", author_pfp=member.avatar.url, color=0x000000, description=f"{member.mention} was banned.", fields=[('User', f"{member}", True), ('User ID', f"{member.id}", True), ('Account Created', f"{membercreated}", True), ('Reason', f"{banevent.reason}", True) ], timestamp=(datetime.utcnow()), footer=f"Ban") print(f'{member} banned.')
async def on_member_remove(self, member): check_log_item(member.guild.id) LeaveChannelID = get_log_item(member.guild.id, "Leave") if LeaveChannelID != 0: if member != "": channel = self.bot.get_channel(LeaveChannelID) membercreated = str(member.created_at.strftime("%b %d, %Y")) g_roles = member.roles g_roles = [f"{role.mention}\n" for role in g_roles] g_roles_str = ''.join(g_roles) await send_embed( channel, send_option=0, author=f"{member} left.", author_pfp=member.avatar.url, color=0xff6e6e, description=f"**Leave event by** {member.mention}", fields=[('User', f"{member}", False), ('User ID', f"{member.id}", False), ('Roles', f"{str(g_roles_str)}", False), ('Account Created', f"{membercreated}", True)], timestamp=(datetime.utcnow()), footer=f"Left") print(f'{member} left.')
async def on_member_join(self, member): check_log_item(member.guild.id) JoinChannelID = get_log_item(member.guild.id, "Join") if JoinChannelID != 0: if member != "": channel = self.bot.get_channel(JoinChannelID) membercreated = str(member.created_at.strftime("%b %d, %Y")) await send_embed( channel, send_option=0, author=f"{member} joined.", author_pfp=member.avatar.url, color=0x6eff90, description=f"**Join event by** {member.mention}", fields=[('User', f"{member}", False), ('User ID', f"{member.id}", False), ('Account Created', f"{membercreated}", True)], timestamp=(datetime.utcnow()), footer=f"Joined") # Print to terminal when a member joins. print(f'{member} joined.') check_global_user(member.id) # Get the welcome message from our SQL database by using our function. welcomemessage = get_welcome_message(member.guild.id) # Make a new var called welcomecardon and set the value to 0. welcomecardon = 0 # Get the welcome card setting(either 0 or 1) from the SQL database welcomecardon = get_welcome_card(member.guild.id) # Get the dm welcome message from our SQL database by using our function. dm_welcomemessage = get_welcome_dm_message(member.guild.id) welcomerole = get_welcome_role(member.guild.id) if welcomerole != "None": for g_role in member.guild.roles: if str(welcomerole) in str(g_role.id): await member.add_roles(g_role) # If the message isn't "None" then if dm_welcomemessage != "None": # Replace our wildcards with the appropriate objects. dm_welcomemessage = dm_welcomemessage.replace( "%USER%", f"{member.mention}") dm_welcomemessage = dm_welcomemessage.replace( "%SERVER%", f"{member.guild}") # Send the welcome message. try: await member.send(dm_welcomemessage) except discord.errors.Forbidden as exception: print(f"{member} has DMS off.") if welcomecardon == 1 and welcomemessage != "None": # Get the welcome channel from the database and set it to a var named channel. channel = self.bot.get_channel(get_welcome_channel( member.guild.id)) # Make a new var called avatarRequest and send a request to download and get the users avatar to it. avatarRequest = (requests.get(member.avatar.url)).content welcomemessage = welcomemessage.replace("%USER%", f"{member.mention}") welcomemessage = welcomemessage.replace("%SERVER%", f"{member.guild}") # Send a message with the file that our create welcome card function returns. await channel.send(file=create_welcome_card( avatarRequest, member, member.guild), content=welcomemessage) return # If the message isn't "None" then if welcomemessage != "None": # Set our channel var to the channel specified in our SQL database. channel = self.bot.get_channel(get_welcome_channel( member.guild.id)) # Replace our wildcards with the appropriate objects. welcomemessage = welcomemessage.replace("%USER%", f"{member.mention}") welcomemessage = welcomemessage.replace("%SERVER%", f"{member.guild}") # Send the welcome message. await channel.send(welcomemessage) return # if the welcome card setting is set to ON(or 1) then if welcomecardon == 1: # Get the welcome channel from the database and set it to a var named channel. channel = self.bot.get_channel(get_welcome_channel( member.guild.id)) # Make a new var called avatarRequest and send a request to download and get the users avatar to it. avatarRequest = (requests.get(member.avatar.url)).content # Send a message with the file that our create welcome card function returns. await channel.send( file=create_welcome_card(avatarRequest, member, member.guild)) return
async def mute(self, ctx, user: discord.Member = None, time: TimeConverter = None, *, reason=None): if user is None: justprefix = await get_prefix(self.bot, ctx.message) await send_embed(ctx, send_option=0, description=f"<:Pogbot_X:850089728018874368> " f"**You must provide a user.**" f"\nTry ```{justprefix[2]}mute User```", color=0x08d5f7) return try: user_member = ctx.guild.get_member(user.id) if user_member.top_role >= ctx.author.top_role: await send_embed(ctx, send_option=0, description=f"<:Pogbot_X:850089728018874368> " f"**The user must have a role below you.**", color=0x08d5f7) return except AttributeError: print("We can't check non members for roles.") role = discord.utils.get(user.guild.roles, name="Muted") if role is None: muted = await ctx.guild.create_role(name="Muted") roles = ctx.me.roles roles.reverse() toprole = roles[0] print(toprole.position) position = toprole.position - 1 await muted.edit(position=position) for channel in ctx.guild.channels: await channel.set_permissions(muted, send_messages=False, read_messages=False, read_message_history=False) overwrites = { ctx.guild.default_role: discord.PermissionOverwrite(read_messages=False), ctx.guild.me: discord.PermissionOverwrite(read_messages=True, send_messages=True), muted: discord.PermissionOverwrite(read_messages=True, send_messages=True) } mutedchannel = await ctx.guild.create_text_channel('muted', overwrites=overwrites) await send_embed(ctx, send_option=0, description=f"<:Pogbot_X:850089728018874368> " f"**No muted role found, so one was created.**", color=0x08d5f7) await user.add_roles(muted) mutereason = reason if reason is None: mutereason = " " await send_embed(ctx, send_option=0, description=f"<:Check:845178458426179605> " f"**{user} has been muted.** {mutereason}", color=0x08d5f7) MutedChannelID = get_log_item(ctx.author.guild.id, "Mute") if MutedChannelID != 0: if user != "": channel = self.bot.get_channel(MutedChannelID) membercreated = str(user.created_at.strftime("%b %d, %Y")) await send_embed(channel, send_option=0, author=f"{user} was muted.", author_pfp=user.avatar.url, color=0x404040, description=f"**{user.mention}** was muted.", fields=[('User', f"{user}", True), ('ID', f"{user.id}", True), ('Duration', f"{time}", True), ('Reason', f"{reason}", True), ('Account Created', f"{membercreated}", True)], timestamp=(datetime.utcnow()), footer=f"Mute") if time: await asyncio.sleep(time) await user.remove_roles(role) MutedChannelID = get_log_item(ctx.author.guild.id, "Mute") if MutedChannelID != 0: if user != "": channel = self.bot.get_channel(MutedChannelID) membercreated = str(user.created_at.strftime("%b %d, %Y")) await send_embed(channel, send_option=0, author=f"{user} was unmuted.", author_pfp=user.avatar.url, color=0x5eff89, description=f"**{user.mention}** was unmuted.", fields=[('User', f"{user}", True), ('ID', f"{user.id}", True), ('Account Created', f"{membercreated}", False), ('Unmuted by', f"Duration Expired", True)], timestamp=(datetime.utcnow()), footer=f"Unmute") # If the Muted role did exist else: await user.add_roles(role) mutereason = reason if reason is None: mutereason = " " await send_embed(ctx, send_option=0, description=f"<:Check:845178458426179605> " f"**{user} has been muted.** {mutereason}", color=0x08d5f7) MutedChannelID = get_log_item(ctx.author.guild.id, "Mute") if MutedChannelID != 0: if user != "": channel = self.bot.get_channel(MutedChannelID) membercreated = str(user.created_at.strftime("%b %d, %Y")) await send_embed(channel, send_option=0, author=f"{user} was muted.", author_pfp=user.avatar.url, color=0x404040, description=f"**{user.mention}** was muted.", fields=[('User', f"{user}", True), ('ID', f"{user.id}", True), ('Duration', f"{time}", False), ('Reason', f"{reason}", True), ('Account Created', f"{membercreated}", False)], timestamp=(datetime.utcnow()), footer=f"Mute") if time: await asyncio.sleep(time) if role in user.roles: await user.remove_roles(role) MutedChannelID = get_log_item(ctx.author.guild.id, "Mute") if MutedChannelID != 0: if user != "": channel = self.bot.get_channel(MutedChannelID) membercreated = str(user.created_at.strftime("%b %d, %Y")) await send_embed(channel, send_option=0, author=f"{user} was unmuted.", author_pfp=user.avatar.url, color=0x5eff89, description=f"**{user.mention}** was unmuted.", fields=[('User', f"{user}", True), ('ID', f"{user.id}", True), ('Account Created', f"{membercreated}", True)], timestamp=(datetime.utcnow()), footer=f"Unmute") return
async def on_voice_state_update(self, member, before, after): print(f'{member} {before.channel} - {after.channel}') if str(before.channel) == "None": print(f"Joined VC to {after.channel}") JoinVCChannelID = get_log_item(member.guild.id, "JoinVC") if JoinVCChannelID != 0: if member != "": channel = self.bot.get_channel(JoinVCChannelID) await send_embed( channel, send_option=0, author=f"{member} joined a voice channel.", author_pfp=member.avatar.url, color=0x42f595, description= f"**{member.mention}** joined voice channel {after.channel.mention}.", fields=[('Channel', f"{after.channel}", True), ('ID', f"{after.channel.id}", True)], timestamp=(datetime.utcnow()), footer=f"Joined voice") return if str(after.channel) == "None": print(f"{member} left VC") LeftVCChannelID = get_log_item(member.guild.id, "LeaveVC") if LeftVCChannelID != 0: if member != "": channel = self.bot.get_channel(LeftVCChannelID) await send_embed( channel, send_option=0, author=f"{member} left voice.", author_pfp=member.avatar.url, color=0xf54242, description= f"**{member.mention}** left voice channel {before.channel.mention}.", fields=[('Channel', f"{before.channel}", True), ('ID', f"{before.channel.id}", True)], timestamp=(datetime.utcnow()), footer=f"Left voice") return if after.channel != before.channel: print(f"User Moved Channels to {after.channel}") MovedVCChannelID = get_log_item(member.guild.id, "MovedVC") if MovedVCChannelID != 0: if member != "": channel = self.bot.get_channel(MovedVCChannelID) await send_embed( channel, send_option=0, author=f"{member} moved in voice.", author_pfp=member.avatar.url, color=0xffd64f, description=f"**{member.mention}** moved from voice " f"channel {before.channel.mention} to {after.channel.mention}.", fields=[('Came from', f"{before.channel}", False), ('ID', f"{before.channel.id}", True), ('Went to', f"{after.channel}", False), ('ID', f"{after.channel.id}", True)], timestamp=(datetime.utcnow()), footer=f"Moved voice") return
async def kick(self, ctx, user: discord.User = None, *, reason=None): if user is None: justprefix = await get_prefix(self.bot, ctx.message) await send_embed(ctx, send_option=0, description=f"<:Pogbot_X:850089728018874368> " f"**You must provide a user.**" f"\nTry ```{justprefix[2]}kick User```", color=0x08d5f7) return try: user_member = ctx.guild.get_member(user.id) if user_member.top_role >= ctx.author.top_role: await send_embed(ctx, send_option=0, description=f"<:Pogbot_X:850089728018874368> " f"**The user must have a role below you.**", color=0x08d5f7) return except AttributeError: print("We can't check non members for roles.") if reason is None: # I've put these here with the idea of building a switch here in the future. # message = f"You've been banned from **{ctx.guild.name}**." # await user.send(message) await ctx.guild.kick(user) await send_embed(ctx, send_option=0, description=f"<:Check:845178458426179605> " f"**{user} has been kicked.**", color=0x08d5f7) KickedChannelID = get_log_item(ctx.author.guild.id, "Kick") if KickedChannelID != 0: if user != "": channel = self.bot.get_channel(KickedChannelID) membercreated = str(user.created_at.strftime("%b %d, %Y")) await send_embed(channel, send_option=0, author=f"{user} was kicked.", author_pfp=user.avatar.url, color=0xa83232, description=f"**{user.mention}** was kicked.", fields=[('User', f"{user}", True), ('ID', f"{user.id}", True), ('Account Created', f"{membercreated}", True)], timestamp=(datetime.utcnow()), footer=f"Kick") return # I've put these here with the idea of building a switch here in the future. # message = f"You've been banned from **{ctx.guild.name}** for **{reason}**." # await user.send(message) await ctx.guild.kick(user, reason=reason) await send_embed(ctx, send_option=0, description=f"<:Check:845178458426179605> " f"**{user} has been kicked.**", color=0x08d5f7) KickedChannelID = get_log_item(ctx.author.guild.id, "Kick") if KickedChannelID != 0: if user != "": channel = self.bot.get_channel(KickedChannelID) membercreated = str(user.created_at.strftime("%b %d, %Y")) await send_embed(channel, send_option=0, author=f"{user} was kicked.", author_pfp=user.avatar.url, color=0xa83232, description=f"**{user.mention}** was kicked.", fields=[('User', f"{user}", True), ('ID', f"{user.id}", True), ('Account Created', f"{membercreated}", True), ('Reason', reason, True)], timestamp=(datetime.utcnow()), footer=f"Kick") return
async def on_member_update(self, before, after): user = before if before.nick != after.nick: check_log_item(before.guild.id) NickChannelID = get_log_item(before.guild.id, "NickChanged") if NickChannelID != 0: if before != "": channel = self.bot.get_channel(NickChannelID) membercreated = str( before.created_at.strftime("%b %d, %Y")) nickname = after.nick if "None" in str(nickname): nickname = "None" await send_embed( channel, send_option=0, author=f"{before} changed nickname.", author_pfp=before.avatar.url, color=0xb9ff6e, description=f"**Nickname event for** {before.mention}", fields=[('User', f"{before}", False), ('**Nickname**', f"**{nickname}**", False), ('User ID', f"{before.id}", False), ('Account Created', f"{membercreated}", True)], timestamp=(datetime.utcnow()), footer=f"Changed Nickname") print( f"[{before.guild}]{user} changed nickname from {before.nick} to {after.nick}" ) if before.roles != after.roles: ldiff = diff_lists(before.roles, after.roles) if ldiff[0]: RolesAddedID = get_log_item(before.guild.id, "RoleGiven") if RolesAddedID != 0: if before != "": channel = self.bot.get_channel(RolesAddedID) RoleName = str(ldiff[0]) RoleID = str(ldiff[0]) RoleName = RoleName.split("name='")[1].split("'>")[0] RoleID = RoleID.split("Role id=")[1].split(" name=")[0] RoleMention = discord.utils.get(before.guild.roles, name=RoleName) await send_embed( channel, send_option=0, author=f"{before} received a role.", author_pfp=before.avatar.url, color=0x7aff97, description= f"**Role** {RoleMention.mention} was given.", fields=[('Role', f"{RoleName}", True), ('ID', f"{RoleID}", True), ('User', f"{before}", False), ('UserID', f"{before.id}", True)], timestamp=(datetime.utcnow()), footer=f"Role received") print(f"{user} role was added: {ldiff[0]}") if ldiff[1]: RolesRemovedID = get_log_item(before.guild.id, "RoleRemoved") if RolesRemovedID != 0: if before != "": channel = self.bot.get_channel(RolesRemovedID) RoleName = str(ldiff[1]) RoleID = str(ldiff[1]) RoleName = RoleName.split("name='")[1].split("'>")[0] RoleID = RoleID.split("Role id=")[1].split(" name=")[0] RoleMention = discord.utils.get(before.guild.roles, name=RoleName) await send_embed( channel, send_option=0, author=f"{before} lost a role.", author_pfp=before.avatar.url, color=0xffce7a, description= f"**Role** {RoleMention.mention} was removed.", fields=[('Role', f"{RoleName}", True), ('ID', f"{RoleID}", True), ('User', f"{before}", False), ('UserID', f"{before.id}", True)], timestamp=(datetime.utcnow()), footer=f"Role removed") print(f"{user} role was removed: {ldiff[1]}") if before.activity != after.activity: return if before.status != after.status: return