Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Logging #50

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add Logging #50

wants to merge 1 commit into from

Conversation

Jonathan5508
Copy link

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

Copy link
Contributor

@VincentRPS VincentRPS left a comment

Choose a reason for hiding this comment

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

camelCase :(

@commands.Cog.listener()
async def on_ready(self):
print("Online!")
setattr(self.client, "db", await aiosqlite.connect("main.db"))
Copy link
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

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
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

@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
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.


@logs.command()
@commands.has_permissions(manage_guild=True)
async def channel(self, ctx, channel: nextcord.TextChannel):
Copy link
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.

await msgDelete.send(embed=embed)

@commands.Cog.listener()
async def on_message_edit(self, before, after):
Copy link
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.

await self.client.db.commit()

@commands.Cog.listener()
async def on_message_delete(self, message):
Copy link
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