11from __future__ import annotations
22
3+ from piccolo .querystring import Unquoted
4+
35from ..botbase import BotBase
46from ..db import CommandLog
57from ..models import CogBase
@@ -18,18 +20,24 @@ async def on_application_command_completion(self, inter: MyInter):
1820 channel = inter .channel .id if inter .guild is not None else None
1921 member = inter .user .id
2022
21- # Incrementing amount without funky sub queries is not possible.
22- await CommandLog .raw (
23- """
24- INSERT INTO command_log (command, guild, channel, member, amount)
25- VALUES ({}, {}, {}, {}, 1)
26- ON CONFLICT (command, guild, channel, member)
27- DO UPDATE SET amount = command_log.amount + 1;
28- """ ,
29- cmd ,
30- guild ,
31- channel ,
32- member ,
23+ await CommandLog .insert (
24+ CommandLog (
25+ {
26+ CommandLog .command : cmd ,
27+ CommandLog .guild : guild ,
28+ CommandLog .channel : channel ,
29+ CommandLog .member : member ,
30+ }
31+ )
32+ ).on_conflict (
33+ (
34+ CommandLog .command ,
35+ CommandLog .guild ,
36+ CommandLog .channel ,
37+ CommandLog .member ,
38+ ),
39+ "DO UPDATE" ,
40+ ((CommandLog .amount , Unquoted ("command_log.amount + 1" )),),
3341 )
3442
3543
0 commit comments