Skip to content

Commit

Permalink
Fixed minor bugs in log system
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinTrinh1227 committed Dec 2, 2023
1 parent 0faa8b0 commit e2a803b
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 39 deletions.
2 changes: 1 addition & 1 deletion commands/ping.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def __init__(self, client):

@commands.hybrid_command(aliases = ["lt", "pong"], brief="ping",description="View bot latency connection", with_app_command=True)
async def ping(self, ctx: commands.Context):
await ctx.channel.purge(limit = 1)
#await ctx.channel.purge(limit = 1)
ping1 = round(self.client.latency * 1000)
ping2 = round(self.client.latency * 1000)
ping3 = round(self.client.latency * 1000)
Expand Down
2 changes: 1 addition & 1 deletion commands/say.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async def say(self, ctx, *, message):
)
embed.timestamp = datetime.datetime.now()
embed.set_footer(text=f"© {ctx.guild.name}", icon_url=ctx.guild.icon.url)
await ctx.channel.purge(limit=1)
#await ctx.channel.purge(limit=1)
await ctx.send(embed=embed)


Expand Down
82 changes: 45 additions & 37 deletions listeners/general_log_listeners.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,53 +199,61 @@ async def on_message_delete(self, message):
async for entry in message.guild.audit_logs(limit=1, action=discord.AuditLogAction.message_delete):
deleter = entry.user

print(entry)
print(message)

channel = self.client.get_channel(logs_channel_id)
#print(entry)
#print(message)
#print(f"{message.author.id} - {self.client.user.id}")

if not message.author.id == self.client.user.id:

embed = discord.Embed(
title=(f"🗑️ | A message was deleted in #{message.channel.name}"),
description=f"**Message deleted:** ```{message.content}```",
colour= embed_color
)
embed.set_author(name=f"{deleter.name} ({deleter.display_name})", icon_url=deleter.avatar.url)
embed.add_field(name="Message Author", value=message.author.mention,
inline=True)
embed.add_field(name="Author Name", value=message.author.name,
inline=True)
embed.add_field(name="Author ID", value=message.author.id,
inline=True)
channel = self.client.get_channel(logs_channel_id)

embed.add_field(name="Deleter", value=deleter.mention,
inline=True)
embed.add_field(name="Deleter Name", value=deleter.name,
inline=True)
embed.add_field(name="Deleter ID", value=deleter.id,
inline=True)
embed = discord.Embed(
title=(f"🗑️ | A message was deleted in #{message.channel.name}"),
description=f"**Message deleted:** ```{message.content}```",
colour= embed_color
)
embed.set_author(name=f"{deleter.name} ({deleter.display_name})", icon_url=deleter.avatar.url)
embed.add_field(name="Message Author", value=message.author.mention,
inline=True)
embed.add_field(name="Author Name", value=message.author.name,
inline=True)
embed.add_field(name="Author ID", value=message.author.id,
inline=True)

embed.add_field(name="Deleter", value=deleter.mention,
inline=True)
embed.add_field(name="Deleter Name", value=deleter.name,
inline=True)
embed.add_field(name="Deleter ID", value=deleter.id,
inline=True)

await channel.send(embed=embed)
await channel.send(embed=embed)


# logs when someone edits a message
@commands.Cog.listener()
async def on_message_edit(self, message_before, message_after):
embed = discord.Embed(
title=f"✂️ | A message was edited in #{message_before.channel.name}",
description=f"**Old Message:**\n```{message_before.content}```\n**New Message:**\n```{message_after.content} ```",
color=0xFF0000
)
embed.set_author(name=f"{message_before.author.name} ({message_before.author.display_name})", icon_url=message_before.author.avatar.url)
embed.add_field(name="Message Author", value=message_before.author.mention,
inline=True)
embed.add_field(name="Author Name", value=message_before.author.name,
inline=True)
embed.add_field(name="Author ID", value=message_before.author.id,
inline=True)

channel = self.client.get_channel(logs_channel_id)
#print(message_before.author.bot)

if not message_before.author.bot:

embed = discord.Embed(
title=f"✂️ | A message was edited in #{message_before.channel.name}",
description=f"**Old Message:**\n```{message_before.content}```\n**New Message:**\n```{message_after.content} ```",
color=0xFF0000
)
embed.set_author(name=f"{message_before.author.name} ({message_before.author.display_name})", icon_url=message_before.author.avatar.url)
embed.add_field(name="Message Author", value=message_before.author.mention,
inline=True)
embed.add_field(name="Author Name", value=message_before.author.name,
inline=True)
embed.add_field(name="Author ID", value=message_before.author.id,
inline=True)

channel = self.client.get_channel(logs_channel_id)

await channel.send(channel, embed=embed)
await channel.send(embed=embed)


async def setup(client):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
"""
Filename: guild_member_updater.py
Description: This module updates your guild members that are inside your discord server.
Updates include guild members' display name in discord.
"""

import discord
from discord.ext import tasks, commands
from datetime import datetime, timedelta
Expand Down

0 comments on commit e2a803b

Please sign in to comment.