make guild count nullable

This commit is contained in:
io mintz 2021-04-06 04:20:06 +00:00
parent ed9f82163e
commit 784ef034f5
2 changed files with 3 additions and 2 deletions

2
bot.py
View File

@ -64,7 +64,7 @@ class Bot(Bot):
user_id_md5 = hashlib.md5(ctx.author.id.to_bytes(8, byteorder='big'), usedforsecurity=False).digest()
await self.pool.execute(
'INSERT INTO invokes (guild_id, user_id_md5, command) VALUES ($1, $2, $3)',
ctx.guild.id, user_id_md5, ctx.command.qualified_name,
getattr(ctx.guild, 'id', None), user_id_md5, ctx.command.qualified_name,
)
# we use on_shard_ready rather than on_ready because the latter is a bit less reliable

View File

@ -2,7 +2,8 @@ SET TIME ZONE 'UTC';
-- inserted for every time a command is invoked
CREATE TABLE invokes (
guild_id BIGINT NOT NULL,
-- nullable because it may be invoked in DMs
guild_id BIGINT,
-- hashed for privacy
user_id_md5 BYTEA NOT NULL,
-- the qualified name of the command invoked (https://discordpy.readthedocs.io/en/stable/ext/commands/api.html?highlight=qualified_name#discord.ext.commands.Command.qualified_name)