-
Notifications
You must be signed in to change notification settings - Fork 17
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
base: main
Are you sure you want to change the base?
Add Logging #50
Conversation
There was a problem hiding this 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")) |
There was a problem hiding this comment.
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]) |
There was a problem hiding this comment.
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,)) |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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.
Add a multi-guild logging system for projglow, using sqlite.