file description module import type { HibikiClient } from "../classes/Client" ; import { convertHex } from "../utils/embed" ; import { dateFormat } from "../utils/format" ; export class ReminderHandler { bot : HibikiClient ; reminders : Reminder [ ] = [ ] ; constructor ( bot ) { this . bot = bot ; setTimeout ( ( ) => { this . bot . db . getAllReminders ( ) . then ( ( reminders ) => ( this . reminders = reminders ) ) ; setInterval ( async ( ) => { this . reminders . forEach ( async ( reminder ) => { if ( Date . now ( ) >= reminder . date ) { const user = bot . users . get ( reminder . user ) ; if ( ! user ) return ; const dm = await user . getDMChannel ( ) . catch ( ( ) => { } ) ; if ( ! dm ) return ; this . reminders . splice ( this . reminders . indexOf ( reminder ) , 1 ) ; await bot . db . deleteUserReminder ( reminder . user , reminder . id ) ; const userLocale = await bot . localeSystem . getUserLocale ( reminder . user , bot ) ; const string = bot . localeSystem . getLocaleFunction ( userLocale ) ; await dm . createMessage ( { embed : { title : `⏰ ${ string ( "utility.REMINDER" ) }` , description : `${ reminder . message }` , color : convertHex ( "general" ) , footer : { text : `${ string ( "utility.REMINDER_SETON" , { date : dateFormat ( reminder . set , string ) } ) }` , icon_url : bot . user . dynamicAvatarURL ( ) , } , } , } ) ; } } ) ; } , 2000 ) ; } , 10000 ) ; } }