GM event fixes

This commit is contained in:
2024-09-21 00:42:08 +02:00
parent 0a629bf80f
commit 6b2433f814
20 changed files with 105 additions and 72 deletions

View File

@ -4,6 +4,7 @@ import path from 'path'
import fs from 'fs'
import prisma from '../../../../utilities/prisma'
import CharacterManager from '../../../../managers/characterManager'
import characterRepository from '../../../../repositories/characterRepository'
interface IPayload {
object: string
@ -16,9 +17,11 @@ interface IPayload {
*/
export default function (socket: TSocket, io: Server) {
socket.on('gm:object:remove', async (data: IPayload, callback: (response: boolean) => void) => {
const character = CharacterManager.getCharacterFromSocket(socket);
if (character?.role !== 'gm') {
return
const character = await characterRepository.getById(socket.characterId as number);
if (!character) return callback(false)
if (character.role !== 'gm') {
return callback(false)
}
try {