Skip to content

Commit

Permalink
!adjustrate command will also refresh autokeys
Browse files Browse the repository at this point in the history
  • Loading branch information
idinium96 committed Jul 31, 2020
1 parent 12071d2 commit eff4c58
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/classes/Commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -617,8 +617,18 @@ export = class Commands {
const sell = { keys: sellKeys, metal: sellMetal };

this.bot.pricelist.adjustKeyRate(buy, sell);
const autokeys = (this.bot.handler as MyHandler).getUserAutokeys();

let reply;
reply = '✅ Key rate adjusted to ' + new Currencies(buy) + '/' + new Currencies(sell);

this.bot.sendMessage(steamID, '✅ Key rate adjusted to ' + new Currencies(buy) + '/' + new Currencies(sell));
if (autokeys.enabled === false) {
reply += '. Autokeys is disabled so no adjustment made on Autokeys.';
} else {
(this.bot.handler as MyHandler).refreshAutoKeys();
reply += '. Autokeys is enabled and has been automatically refreshed.';
}
this.bot.sendMessage(steamID, reply);
}

private messageCommand(steamID: SteamID, message: string): void {
Expand Down
24 changes: 24 additions & 0 deletions src/classes/MyHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2184,6 +2184,30 @@ Autokeys status:-
});
}

refreshAutoKeys(): void {
const isKeysAlreadyExist = this.bot.pricelist.searchByName('Mann Co. Supply Crate Key', false);
if (isKeysAlreadyExist) {
this.bot.pricelist
.removePrice('5021;6', true)
.then(() => {
log.debug(`✅ Automatically remove Mann Co. Supply Crate Key.`);
this.isBuyingKeys = false;
this.isBankingKeys = false;
this.checkAutokeysStatus = false;
this.checkAlertOnLowPure = false;
this.alreadyUpdatedToBank = false;
this.alreadyUpdatedToBuy = false;
this.alreadyUpdatedToSell = false;
})
.catch(err => {
log.warn(`❌ Failed to remove Mann Co. Supply Crate Key automatically: ${err.message}`);
this.checkAutokeysStatus = true;
});
}
this.sleep(2000);
this.autokeys();
}

private keepMetalSupply(): void {
if (process.env.DISABLE_CRAFTING === 'true') {
return;
Expand Down

0 comments on commit eff4c58

Please sign in to comment.