fix: don't throw an error if questKey already exists #1003
@ -331,9 +331,8 @@ export const addItem = async (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        if (key.chainStages) {
 | 
					        if (key.chainStages) {
 | 
				
			||||||
            const key = addQuestKey(inventory, { ItemType: typeName });
 | 
					            const key = addQuestKey(inventory, { ItemType: typeName });
 | 
				
			||||||
            if (key) {
 | 
					            if (!key) return { InventoryChanges: {} };
 | 
				
			||||||
            return { InventoryChanges: { QuestKeys: [key] } };
 | 
					            return { InventoryChanges: { QuestKeys: [key] } };
 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            const key = { ItemType: typeName, ItemCount: quantity };
 | 
					            const key = { ItemType: typeName, ItemCount: quantity };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -77,7 +77,7 @@ export const updateQuestStage = (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
export const addQuestKey = (inventory: TInventoryDatabaseDocument, questKey: IQuestKeyDatabase) => {
 | 
					export const addQuestKey = (inventory: TInventoryDatabaseDocument, questKey: IQuestKeyDatabase) => {
 | 
				
			||||||
    if (inventory.QuestKeys.some(q => q.ItemType === questKey.ItemType)) {
 | 
					    if (inventory.QuestKeys.some(q => q.ItemType === questKey.ItemType)) {
 | 
				
			||||||
        logger.error(`quest key ${questKey.ItemType} already exists`);
 | 
					        logger.warn(`Quest key ${questKey.ItemType} already exists. It will not be added`);
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    const index = inventory.QuestKeys.push(questKey);
 | 
					    const index = inventory.QuestKeys.push(questKey);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user