Skip to content

Commit

Permalink
fix !adjustrate command with autokeys enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
idinium96 committed Jul 31, 2020
1 parent 9cc5abe commit bed1acd
Showing 1 changed file with 36 additions and 20 deletions.
56 changes: 36 additions & 20 deletions src/classes/MyHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1948,13 +1948,15 @@ Autokeys status:-
}

private createAutokeysSell(userMinKeys: number, userMaxKeys: number): void {
const keyPrice = this.bot.pricelist.getKeyPrices();
const keyPrices = this.bot.pricelist.getKeyPrices();
let entry;
if (this.isUsingAutoPrice) {
entry = {
sku: '5021;6',
enabled: true,
autoprice: true,
autoprice: false,
buy: { keys: keyPrices.buy.keys, metal: keyPrices.buy.metal },
sell: { keys: keyPrices.sell.keys, metal: keyPrices.sell.metal },
max: userMaxKeys,
min: userMinKeys,
intent: 1
Expand All @@ -1966,11 +1968,11 @@ Autokeys status:-
autoprice: false,
sell: {
keys: 0,
metal: Currencies.toRefined(keyPrice.sell.toValue() - this.scrapAdjustmentValue)
metal: Currencies.toRefined(keyPrices.sell.toValue() - this.scrapAdjustmentValue)
},
buy: {
keys: 0,
metal: Currencies.toRefined(keyPrice.buy.toValue() - this.scrapAdjustmentValue)
metal: Currencies.toRefined(keyPrices.buy.toValue() - this.scrapAdjustmentValue)
},
max: userMaxKeys,
min: userMinKeys,
Expand All @@ -1989,13 +1991,15 @@ Autokeys status:-
}

private createAutokeysBuy(userMinKeys: number, userMaxKeys: number): void {
const keyPrice = this.bot.pricelist.getKeyPrices();
const keyPrices = this.bot.pricelist.getKeyPrices();
let entry;
if (this.isUsingAutoPrice) {
entry = {
sku: '5021;6',
enabled: true,
autoprice: true,
autoprice: false,
buy: { keys: keyPrices.buy.keys, metal: keyPrices.buy.metal },
sell: { keys: keyPrices.sell.keys, metal: keyPrices.sell.metal },
max: userMaxKeys,
min: userMinKeys,
intent: 0
Expand All @@ -2007,11 +2011,11 @@ Autokeys status:-
autoprice: false,
sell: {
keys: 0,
metal: Currencies.toRefined(keyPrice.sell.toValue() + this.scrapAdjustmentValue)
metal: Currencies.toRefined(keyPrices.sell.toValue() + this.scrapAdjustmentValue)
},
buy: {
keys: 0,
metal: Currencies.toRefined(keyPrice.buy.toValue() + this.scrapAdjustmentValue)
metal: Currencies.toRefined(keyPrices.buy.toValue() + this.scrapAdjustmentValue)
},
max: userMaxKeys,
min: userMinKeys,
Expand All @@ -2030,10 +2034,13 @@ Autokeys status:-
}

private createAutokeysBanking(userMinKeys: number, userMaxKeys: number): void {
const keyPrices = this.bot.pricelist.getKeyPrices();
const entry = {
sku: '5021;6',
enabled: true,
autoprice: true,
autoprice: false,
buy: { keys: keyPrices.buy.keys, metal: keyPrices.buy.metal },
sell: { keys: keyPrices.sell.keys, metal: keyPrices.sell.metal },
max: userMaxKeys,
min: userMinKeys,
intent: 2
Expand Down Expand Up @@ -2070,13 +2077,15 @@ Autokeys status:-
}

private updateAutokeysSell(userMinKeys: number, userMaxKeys: number): void {
const keyPrice = this.bot.pricelist.getKeyPrices();
const keyPrices = this.bot.pricelist.getKeyPrices();
let entry;
if (this.isUsingAutoPrice) {
entry = {
sku: '5021;6',
enabled: true,
autoprice: true,
autoprice: false,
buy: { keys: keyPrices.buy.keys, metal: keyPrices.buy.metal },
sell: { keys: keyPrices.sell.keys, metal: keyPrices.sell.metal },
max: userMaxKeys,
min: userMinKeys,
intent: 1
Expand All @@ -2088,11 +2097,11 @@ Autokeys status:-
autoprice: false,
sell: {
keys: 0,
metal: Currencies.toRefined(keyPrice.sell.toValue() - this.scrapAdjustmentValue)
metal: Currencies.toRefined(keyPrices.sell.toValue() - this.scrapAdjustmentValue)
},
buy: {
keys: 0,
metal: Currencies.toRefined(keyPrice.buy.toValue() - this.scrapAdjustmentValue)
metal: Currencies.toRefined(keyPrices.buy.toValue() - this.scrapAdjustmentValue)
},
max: userMaxKeys,
min: userMinKeys,
Expand All @@ -2111,13 +2120,15 @@ Autokeys status:-
}

private updateAutokeysBuy(userMinKeys: number, userMaxKeys: number): void {
const keyPrice = this.bot.pricelist.getKeyPrices();
const keyPrices = this.bot.pricelist.getKeyPrices();
let entry;
if (this.isUsingAutoPrice) {
entry = {
sku: '5021;6',
enabled: true,
autoprice: true,
autoprice: false,
buy: { keys: keyPrices.buy.keys, metal: keyPrices.buy.metal },
sell: { keys: keyPrices.sell.keys, metal: keyPrices.sell.metal },
max: userMaxKeys,
min: userMinKeys,
intent: 0
Expand All @@ -2129,11 +2140,11 @@ Autokeys status:-
autoprice: false,
sell: {
keys: 0,
metal: Currencies.toRefined(keyPrice.sell.toValue() + this.scrapAdjustmentValue)
metal: Currencies.toRefined(keyPrices.sell.toValue() + this.scrapAdjustmentValue)
},
buy: {
keys: 0,
metal: Currencies.toRefined(keyPrice.buy.toValue() + this.scrapAdjustmentValue)
metal: Currencies.toRefined(keyPrices.buy.toValue() + this.scrapAdjustmentValue)
},
max: userMaxKeys,
min: userMinKeys,
Expand All @@ -2152,10 +2163,13 @@ Autokeys status:-
}

private updateAutokeysBanking(userMinKeys: number, userMaxKeys: number): void {
const keyPrices = this.bot.pricelist.getKeyPrices();
const entry = {
sku: '5021;6',
enabled: true,
autoprice: true,
autoprice: false,
buy: { keys: keyPrices.buy.keys, metal: keyPrices.buy.metal },
sell: { keys: keyPrices.sell.keys, metal: keyPrices.sell.metal },
max: userMaxKeys,
min: userMinKeys,
intent: 2
Expand Down Expand Up @@ -2198,14 +2212,16 @@ Autokeys status:-
this.alreadyUpdatedToBank = false;
this.alreadyUpdatedToBuy = false;
this.alreadyUpdatedToSell = false;
this.sleep(2000);
this.autokeys();
})
.catch(err => {
log.warn(`❌ Failed to remove Mann Co. Supply Crate Key automatically: ${err.message}`);
this.checkAutokeysStatus = true;
});
} else {
this.autokeys();
}
this.sleep(2000);
this.autokeys();
}

private keepMetalSupply(): void {
Expand Down

0 comments on commit bed1acd

Please sign in to comment.