Skip to content

Add Logging#50

Open
Jonathan5508 wants to merge 1 commit into
apat7:mainfrom
Jonathan5508:main
Open

Add Logging#50
Jonathan5508 wants to merge 1 commit into
apat7:mainfrom
Jonathan5508:main

Conversation

@Jonathan5508

Copy link
Copy Markdown

Add a multi-guild logging system for projglow, using sqlite.

@VincentRPS VincentRPS left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

camelCase :(

Comment thread cogs/logs.py
@commands.Cog.listener()
async def on_ready(self):
print("Online!")
setattr(self.client, "db", await aiosqlite.connect("main.db"))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please, typehint self.client.db

Comment thread cogs/logs.py
async with self.client.db.cursor() as cursor:
await cursor.execute("SELECT channel FROM logging WHERE guild = ?", (guild.id,))
channelID = await cursor.fetchone()
chanDelete = self.client.get_channel(channelID[0])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wtf camelcase? this should be snakecase iirc

Comment thread cogs/logs.py
@commands.has_permissions(manage_guild=True)
async def channel(self, ctx, channel: nextcord.TextChannel):
async with self.client.db.cursor() as cursor:
await cursor.execute("SELECT channel FROM logging WHERE guild = ?", (ctx.guild.id,))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you do know this gives back a list of channel_ids, right?

the filter should include the channel_id, if you really want to be particular.

Comment thread cogs/logs.py

@logs.command()
@commands.has_permissions(manage_guild=True)
async def channel(self, ctx, channel: nextcord.TextChannel):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems like there is no way to disable logging?
also, the name for this--channel--seems improper.

Comment thread cogs/logs.py
await msgDelete.send(embed=embed)

@commands.Cog.listener()
async def on_message_edit(self, before, after):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

quick thing, there is a possibility of before being None on any update or edit event.

Comment thread cogs/logs.py
await self.client.db.commit()

@commands.Cog.listener()
async def on_message_delete(self, message):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iirc, this is dependent on the message being cached, if its not this would probably raise an error since message.author does not exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants