forked from noxious/server
Renamed zone > map
This commit is contained in:
29
src/events/gameMaster/mapEditor/delete.ts
Normal file
29
src/events/gameMaster/mapEditor/delete.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import { BaseEvent } from '#application/base/baseEvent'
|
||||
import { UUID } from '#application/types'
|
||||
import MapRepository from '#repositories/mapRepository'
|
||||
|
||||
type Payload = {
|
||||
mapId: UUID
|
||||
}
|
||||
|
||||
export default class MapDeleteEvent extends BaseEvent {
|
||||
public listen(): void {
|
||||
this.socket.on('gm:map_editor:map:delete', this.handleEvent.bind(this))
|
||||
}
|
||||
|
||||
private async handleEvent(data: Payload, callback: (response: boolean) => void): Promise<void> {
|
||||
if (!(await this.isCharacterGM())) return
|
||||
|
||||
try {
|
||||
this.logger.info(`Deleting map ${data.mapId}`)
|
||||
|
||||
await (await MapRepository.getById(data.mapId))?.delete()
|
||||
|
||||
this.logger.info(`Map ${data.mapId} deleted successfully.`)
|
||||
return callback(true)
|
||||
} catch (error: unknown) {
|
||||
this.logger.error('gm:map_editor:map:delete error', error)
|
||||
return callback(false)
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user