Add Logging#50
Conversation
| @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.
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.
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.
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.
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.
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.
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.