getDialogue function error when a player reached 1999 but never talked to the hex and do a bounty #2678

Closed
opened 2025-08-21 21:08:20 -07:00 by AlexisinGit · 0 comments
Contributor

So I just finished 1999 quest and went straight to the bounties. Upon extraction pops warning can't update account.

 error:  TypeError: Cannot read properties of undefined (reading 'Dialogues') while processing /api/missionInventoryUpdate.php request
    at getDialogue (D:\GithubRepos\SpaceNinjaServer\src\services\inventoryService.ts:2292:47)
    at addMissionRewards (D:\GithubRepos\SpaceNinjaServer\src\services\missionInventoryUpdateService.ts:1551:41)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async missionInventoryUpdateController (D:\GithubRepos\SpaceNinjaServer\src\controllers\api\missionInventoryUpdateController.ts:96:9)

It seems like the getDialogue function don't know what to do if a player's Dialogues never exists.

I asked ai to fix it. It fixed my game anyway. Here goes the code.

export const getDialogue = (inventory: TInventoryDatabaseDocument, dialogueName: string): IDialogueDatabase => {
    // Ensure DialogueHistory and Dialogues exists
    if (!inventory.DialogueHistory) {
        inventory.DialogueHistory = { Dialogues: [] };
    }
    
    if (!inventory.DialogueHistory.Dialogues) {
        inventory.DialogueHistory.Dialogues = [];
    }
    
    let dialogue = inventory.DialogueHistory.Dialogues.find(x => x.DialogueName === dialogueName);
    
    if (!dialogue) {
        const newDialogue: IDialogueDatabase = {
            Rank: 0,
            Chemistry: 0,
            AvailableDate: new Date(0),
            AvailableGiftDate: new Date(0),
            RankUpExpiry: new Date(0),
            BountyChemExpiry: new Date(0),
            QueuedDialogues: [],
            Gifts: [],
            Booleans: [],
            Completed: [],
            DialogueName: dialogueName
        };
        
        inventory.DialogueHistory.Dialogues.push(newDialogue);
        dialogue = newDialogue;
    }
    
    return dialogue;
};
So I just finished 1999 quest and went straight to the bounties. Upon extraction pops warning can't update account. ``` error: TypeError: Cannot read properties of undefined (reading 'Dialogues') while processing /api/missionInventoryUpdate.php request at getDialogue (D:\GithubRepos\SpaceNinjaServer\src\services\inventoryService.ts:2292:47) at addMissionRewards (D:\GithubRepos\SpaceNinjaServer\src\services\missionInventoryUpdateService.ts:1551:41) at process.processTicksAndRejections (node:internal/process/task_queues:105:5) at async missionInventoryUpdateController (D:\GithubRepos\SpaceNinjaServer\src\controllers\api\missionInventoryUpdateController.ts:96:9) ``` It seems like the getDialogue function don't know what to do if a player's Dialogues never exists. I asked ai to fix it. It fixed my game anyway. Here goes the code. ``` export const getDialogue = (inventory: TInventoryDatabaseDocument, dialogueName: string): IDialogueDatabase => { // Ensure DialogueHistory and Dialogues exists if (!inventory.DialogueHistory) { inventory.DialogueHistory = { Dialogues: [] }; } if (!inventory.DialogueHistory.Dialogues) { inventory.DialogueHistory.Dialogues = []; } let dialogue = inventory.DialogueHistory.Dialogues.find(x => x.DialogueName === dialogueName); if (!dialogue) { const newDialogue: IDialogueDatabase = { Rank: 0, Chemistry: 0, AvailableDate: new Date(0), AvailableGiftDate: new Date(0), RankUpExpiry: new Date(0), BountyChemExpiry: new Date(0), QueuedDialogues: [], Gifts: [], Booleans: [], Completed: [], DialogueName: dialogueName }; inventory.DialogueHistory.Dialogues.push(newDialogue); dialogue = newDialogue; } return dialogue; }; ```
AlexisinGit changed title from getDialogue function error when a player reached 1999 but never talked to the hex to getDialogue function error when a player reached 1999 but never talked to the hex and do a bounty 2025-08-21 21:10:34 -07:00
Sainan added the
bug
label 2025-08-21 21:28:58 -07:00
Sainan added the
pr'd for
label 2025-08-21 21:30:45 -07:00
Sign in to join this conversation.
No description provided.