Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔨Temporarily disable item with ppu if failed to update #1472

Merged
merged 1 commit into from
Jan 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 28 additions & 8 deletions src/classes/MyHandler/offer/accepted/updateListings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -583,18 +583,38 @@ export default function updateListings(
if (isPricecheckRequestEnabled) addToQ(priceKey, isNotPure, existsInPricelist);
})
.catch(err => {
const msg = `❌ Failed to automatically update prices for ${name} (${priceKey}): ${
let msg = `❌ Failed to automatically update partially priced for ${name} (${priceKey}) and the item has been temporarily disabled.\n\nError: ${
(err as Error).message
}`;
log.error(`❌ Failed to automatically update prices for ${priceKey}`, err);

if (opt.sendAlert.enable && opt.sendAlert.partialPrice.onFailedUpdatePartialPriced) {
if (dwEnabled) {
sendAlert('autoUpdatePartialPriceFailed', bot, msg);
} else {
bot.messageAdmins(msg, []);
}
}
entry.autoprice = false;
entry.enabled = false;
bot.pricelist
.updatePrice({ priceKey: entry.sku, entryData: entry, emitChange: true })
.then(() => {
log.info(`${name} (${priceKey}) has been temporarily disabled.`);

if (opt.sendAlert.enable && opt.sendAlert.partialPrice.onFailedUpdatePartialPriced) {
if (dwEnabled) {
sendAlert('autoUpdatePartialPriceFailed', bot, msg);
} else {
bot.messageAdmins(msg, []);
}
}
})
.catch(err => {
log.error(`Error disabling ${name} (${priceKey}):`, err);

if (opt.sendAlert.enable && opt.sendAlert.partialPrice.onFailedUpdatePartialPriced) {
if (dwEnabled) {
msg = `❌ Failed to automatically disable partially priced ${name} (${priceKey}) after failing to get the latest item price.`;
sendAlert('autoUpdatePartialPriceFailedToDisable', bot, msg);
} else {
bot.messageAdmins(msg, []);
}
}
});

if (isPricecheckRequestEnabled) addToQ(priceKey, isNotPure, existsInPricelist);
});
Expand Down
7 changes: 7 additions & 0 deletions src/lib/DiscordWebhook/sendAlert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type AlertType =
| 'error-accept'
| 'autoUpdatePartialPriceSuccess'
| 'autoUpdatePartialPriceFailed'
| 'autoUpdatePartialPriceFailedToDisable'
| 'autoResetPartialPrice'
| 'autoResetPartialPriceBulk'
| 'onBulkUpdatePartialPriced'
Expand Down Expand Up @@ -156,6 +157,10 @@ export default function sendAlert(
title = 'Failed update item prices (Partial price update)';
description = msg;
color = '16711680'; // red
} else if (type === 'autoUpdatePartialPriceFailedToDisable') {
title = 'Failed disabling item (Partial price update failed)';
description = msg;
color = '16711680'; // red
} else if (type === 'autoResetPartialPrice') {
title = '✅ Automatically reset partially priced item';
description = msg;
Expand Down Expand Up @@ -256,6 +261,7 @@ export default function sendAlert(
'escrow-check-failed-not-restart-bptf-down',
'queue-problem-not-restart-bptf-down',
'autoAddPaintedItemsFailed',
'autoUpdatePartialPriceFailedToDisable',
'failed-accept',
'error-accept',
'unusualInvalidItems'
Expand All @@ -282,6 +288,7 @@ export default function sendAlert(
[
'autoUpdatePartialPriceSuccess',
'autoUpdatePartialPriceFailed',
'autoUpdatePartialPriceFailedToDisable',
'autoResetPartialPrice',
'autoResetPartialPriceBulk',
'onBulkUpdatePartialPriced',
Expand Down