Skip to content

Commit

Permalink
⏮ revert #500
Browse files Browse the repository at this point in the history
  • Loading branch information
idinium96 committed Mar 29, 2021
1 parent 7dc5577 commit e5e1910
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/classes/Commands/Commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default class Commands {
this.message = new c.MessageCommand(bot);
this.misc = new c.MiscCommands(bot);
this.opt = new c.OptionsCommand(bot);
this.pManager = new c.PricelistManager(bot, pricer);
this.pManager = new c.PricelistManager(bot);
this.request = new c.RequestCommands(bot, pricer);
this.review = new c.ReviewCommands(bot);
this.status = new c.StatusCommands(bot);
Expand Down
29 changes: 1 addition & 28 deletions src/classes/Commands/sub-classes/PricelistManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { removeLinkProtocol, testSKU, getItemFromParams, fixSKU } from '../funct
import Bot from '../../Bot';
import CommandParser from '../../CommandParser';
import { Entry, EntryData, PricelistChangedSource } from '../../Pricelist';
import Pricer, { RequestCheckResponse, RequestCheckFn } from '../../Pricer';
import validator from '../../../lib/validator';
import log from '../../../lib/logger';

Expand All @@ -26,30 +25,12 @@ export default class PricelistManagerCommands {

private executeTimeout: NodeJS.Timeout;

private requestCheck: RequestCheckFn;

stopAutoAddCommand(): void {
this.stopAutoAdd = true;
}

constructor(private readonly bot: Bot, private priceSource: Pricer) {
constructor(private readonly bot: Bot) {
this.bot = bot;
this.requestCheck = this.priceSource.requestCheck.bind(this.priceSource);
}

private requestPricecheck(entry: Entry): void {
void this.requestCheck(entry.sku, 'bptf').asCallback((err: ErrorRequest, body: RequestCheckResponse) => {
if (err) {
log.debug(`❌ Failed to request pricecheck for ${entry.sku}: ${JSON.stringify(err)}`);
return;
}

if (!body) {
log.debug(`❌ Error while requesting price check for ${entry.sku} (returned null/undefined).`);
} else {
log.debug(`✅ Requested pricecheck for ${body.name} (${entry.sku}).`);
}
});
}

addCommand(steamID: SteamID, message: string): void {
Expand Down Expand Up @@ -184,8 +165,6 @@ export default class PricelistManagerCommands {
steamID,
`✅ Added "${entry.name}" (${entry.sku})` + this.generateAddedReply(isPremium, entry)
);

this.requestPricecheck(entry);
})
.catch(err => {
this.bot.sendMessage(steamID, `❌ Failed to add the item to the pricelist: ${(err as Error).message}`);
Expand Down Expand Up @@ -429,8 +408,6 @@ export default class PricelistManagerCommands {
total - added - skipped - failed
} remaining`
);

this.requestPricecheck(entry);
})
.catch(err => {
failed++;
Expand Down Expand Up @@ -929,8 +906,6 @@ export default class PricelistManagerCommands {
steamID,
`✅ Updated "${entry.name}" (${entry.sku})` + this.generateUpdateReply(isPremium, itemEntry, entry)
);

this.requestPricecheck(entry);
})
.catch((err: ErrorRequest) => {
this.bot.sendMessage(
Expand Down Expand Up @@ -1174,8 +1149,6 @@ export default class PricelistManagerCommands {
.removePrice(params.sku as string, true)
.then(entry => {
this.bot.sendMessage(steamID, `✅ Removed "${entry.name}".`);

this.requestPricecheck(entry);
})
.catch(err =>
this.bot.sendMessage(steamID, `❌ Failed to remove pricelist entry: ${(err as Error).message}`)
Expand Down

0 comments on commit e5e1910

Please sign in to comment.