diff --git a/src/classes/MyHandler/MyHandler.ts b/src/classes/MyHandler/MyHandler.ts index 153fe829a..41dd56e62 100644 --- a/src/classes/MyHandler/MyHandler.ts +++ b/src/classes/MyHandler/MyHandler.ts @@ -258,13 +258,13 @@ export default class MyHandler extends Handler { keepMetalSupply(this.bot, this.minimumScrap, this.minimumReclaimed, this.combineThreshold); // Craft duplicate weapons - void craftDuplicateWeapons(this.bot); - - // Craft class weapons - this.classWeaponsTimeout = setTimeout(() => { - // called after 5 seconds to craft metals and duplicated weapons first. - void craftClassWeapons(this.bot); - }, 5 * 1000); + craftDuplicateWeapons(this.bot) + .then(() => { + return craftClassWeapons(this.bot); + }) + .catch(err => { + log.warn('Failed to craft duplicated craft/class weapons', err); + }); } if (this.isDeletingUntradableJunk) { @@ -2205,18 +2205,14 @@ export default class MyHandler extends Handler { // Smelt / combine metal keepMetalSupply(this.bot, this.minimumScrap, this.minimumReclaimed, this.combineThreshold); - // Craft duplicated weapons - void craftDuplicateWeapons(this.bot); - - this.classWeaponsTimeout = setTimeout(() => { - // called after 5 second to craft metals and duplicated weapons first. - void craftClassWeapons(this.bot); - }, 5 * 1000); - } - - if (this.isDeletingUntradableJunk) { - // Delete untradable junk - this.deleteUntradableJunk(); + // Craft duplicate weapons + craftDuplicateWeapons(this.bot) + .then(() => { + return craftClassWeapons(this.bot); + }) + .catch(err => { + log.warn('Failed to craft duplicated craft/class weapons', err); + }); } // Sort inventory @@ -2546,7 +2542,9 @@ export default class MyHandler extends Handler { for (const assetid of assetidsToDelete) { log.debug(`Deleting junk item ${assetid}`); - this.bot.tf2gc.deleteItem(assetid); + this.bot.tf2gc.deleteItem(assetid, err => { + log.warn('Error deleting untradable junk', err); + }); } } diff --git a/src/classes/MyHandler/utils/craftClassWeapons.ts b/src/classes/MyHandler/utils/craftClassWeapons.ts index e8a780419..db698947d 100644 --- a/src/classes/MyHandler/utils/craftClassWeapons.ts +++ b/src/classes/MyHandler/utils/craftClassWeapons.ts @@ -17,13 +17,13 @@ export type ClassesForCraftableWeapons = export type SlotsForCraftableWeapons = 'primary' | 'secondary' | 'melee' | 'pda2'; -export default function craftClassWeapons(bot: Bot): Promise { +export default async function craftClassWeapons(bot: Bot): Promise { if (!bot.options.crafting.weapons.enable) { return; } const currencies = bot.inventoryManager.getInventory.getCurrencies(bot.craftWeapons, false); - void Promise.all( + await Promise.all( ['scout', 'soldier', 'pyro', 'demoman', 'heavy', 'engineer', 'medic', 'sniper', 'spy'].map(classChar => craftEachClassWeapons(bot, bot.craftWeaponsByClass[classChar as ClassesForCraftableWeapons], currencies) )