11import type { GuildMember , Snowflake , User } from "discord.js" ;
2+ import type { Temporal } from "@js-temporal/polyfill" ;
23
34import type { Ban } from "./db/model.ts" ;
45import db from "#db" ;
56import log from "#log" ;
67
78export async function persistOrUpdate (
89 user : GuildMember ,
9- until : Date | null ,
10+ until : Temporal . Instant | null ,
1011 isSelfBan : boolean ,
1112 reason : string | null = null ,
1213 ctx = db ( ) ,
@@ -15,7 +16,7 @@ export async function persistOrUpdate(
1516 `Saving Ban for user ${ user } until ${ until } (is self ban: ${ isSelfBan } , reason: ${ reason } )` ,
1617 ) ;
1718
18- const bannedUntil = until ?. toISOString ( ) ;
19+ const bannedUntil = until ?. toString ( ) ;
1920 await ctx
2021 . insertInto ( "bans" )
2122 . values ( {
@@ -42,11 +43,11 @@ export async function remove(userId: Snowflake, ctx = db()) {
4243 await ctx . deleteFrom ( "bans" ) . where ( "userId" , "=" , userId ) . execute ( ) ;
4344}
4445
45- export async function findExpiredBans ( now : Date , ctx = db ( ) ) : Promise < Ban [ ] > {
46+ export async function findExpiredBans ( now : Temporal . Instant , ctx = db ( ) ) : Promise < Ban [ ] > {
4647 return ctx
4748 . selectFrom ( "bans" )
4849 . where ( "bannedUntil" , "is not" , null )
49- . where ( "bannedUntil" , "<=" , now . toISOString ( ) )
50+ . where ( "bannedUntil" , "<=" , now . toString ( ) )
5051 . selectAll ( )
5152 . execute ( ) ;
5253}
0 commit comments