import { Client , Constants , DQConstants , TextChannel } from 'discord.js' ; const { Events } = Constants as DQConstants ; abstract class ActionClass { public client : Client ; constructor ( client ) { this . client = client ; } abstract handle ( data ) ; } const Action = require ( 'discord.js/src/client/actions/Action' ) ; export class MessageAcknowledgedAction extends Action { handle ( data ) { const { client } = this ; const channel = client . channels . resolve ( data . channel_id ) as TextChannel ; const state = client . read_state . find ( ( s ) => s . id === data . channel_id ) ; const message = channel . messages . resolve ( data . message_id ) ; if ( ! state || ! channel || ! message ) { return undefined ; } state . last_message_id = data . message_id ; event param { GuildChannel } channel param { Message } message client . emit ( Events . MESSAGE_ACK , channel , message ) ; return data ; } } export class UserNoteUpdateAction extends Action { handle ( data ) { const { client } = this ; const oldNote = client . user ?. notes . get ( data . id ) ; const note = data . note . length ? data . note : null ; client . user ?. notes . set ( data . id , note ) ; client . emit ( Events . USER_NOTE_UPDATE , data . id , oldNote , note ) ; return { old : oldNote , updated : note , } ; } } export class UserSettingsUpdateAction extends Action { handle ( settings ) { const { client } = this ; if ( 'status' in settings ) { client . presence . status = settings . status ; } event param { ClientUserSettings } settings client . emit ( Events . USER_SETTINGS_UPDATE , settings ) ; return { settings } ; } }