import { BaseEvent } from '#application/base/baseEvent' import { Map } from '#entities/map' import MapRepository from '#repositories/mapRepository' interface IPayload {} export default class MapListEvent extends BaseEvent { public listen(): void { this.socket.on('gm:map:list', this.handleEvent.bind(this)) } private async handleEvent(data: IPayload, callback: (response: Map[]) => void): Promise { try { if (!(await this.isCharacterGM())) return this.logger.info(`User ${(await this.getCharacter())!.getId()} has listed maps via map editor.`) const mapRepository = new MapRepository() const maps = await mapRepository.getAll() return callback(maps) } catch (error: any) { this.logger.error('gm:map:list error', error.message) return callback([]) } } }