From df035c9bb353b1115249d7d8c6801131a2ac0021 Mon Sep 17 00:00:00 2001 From: Junior <42356930+juniorISO69960@users.noreply.github.com> Date: Thu, 25 Jul 2024 16:53:09 -0500 Subject: [PATCH 1/3] fixed a typo in sendTradeDeclined --- src/classes/DiscordWebhook/sendTradeDeclined.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/classes/DiscordWebhook/sendTradeDeclined.ts b/src/classes/DiscordWebhook/sendTradeDeclined.ts index c0e2efdc6..b5d0580af 100644 --- a/src/classes/DiscordWebhook/sendTradeDeclined.ts +++ b/src/classes/DiscordWebhook/sendTradeDeclined.ts @@ -71,7 +71,7 @@ export default async function sendTradeDeclined( const declinedDescription = declined.reasonDescription; const declinedTradeSummary: Webhook = { username: optDW.displayName || botInfo.name, - avatar_url: optDW.avatarURL || optDW.avatarURL, + avatar_url: optDW.avatarURL || botInfo.avatarURL, content: '', embeds: [ { From 5075b33248da1b70b9a16fd15be0521cc7b9074c Mon Sep 17 00:00:00 2001 From: Junior <42356930+juniorISO69960@users.noreply.github.com> Date: Thu, 25 Jul 2024 17:04:59 -0500 Subject: [PATCH 2/3] support for disabling items on both sides of a trade --- src/classes/MyHandler/MyHandler.ts | 14 ++++++++++++++ src/classes/MyHandler/offer/notify/declined.ts | 3 +++ src/classes/Options.ts | 8 +++++++- src/schemas/options-json/options.ts | 16 +++++++++++++++- 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/classes/MyHandler/MyHandler.ts b/src/classes/MyHandler/MyHandler.ts index ab2d7634b..a05e0e064 100644 --- a/src/classes/MyHandler/MyHandler.ts +++ b/src/classes/MyHandler/MyHandler.ts @@ -761,6 +761,20 @@ export default class MyHandler extends Handler { }; } + // Check if the offer has items on both sides + if ( + !opt.miscSettings.itemsOnBothSides.enable && + exchange['our'].contains.items && + exchange['their'].contains.items + ) { + offer.log('info', 'offer has items on both sides'); + return { + action: 'decline', + reason: 'CONTAINS_ITEMS_ON_BOTH_SIDES', + meta: isContainsHighValue ? { highValue: highValueMeta } : undefined + }; + } + const itemsToGiveCount = offer.itemsToGive.length; const itemsToReceiveCount = offer.itemsToReceive.length; diff --git a/src/classes/MyHandler/offer/notify/declined.ts b/src/classes/MyHandler/offer/notify/declined.ts index 6904706b3..0e8cd2306 100644 --- a/src/classes/MyHandler/offer/notify/declined.ts +++ b/src/classes/MyHandler/offer/notify/declined.ts @@ -217,6 +217,9 @@ export default function declined(offer: TradeOffer, bot: Bot): void { reply = custom ? custom : declined + ' because the offer sent contains Mann Co. Supply Crate Key on both sides.'; + } else if (offerReason.reason === 'CONTAINS_ITEMS_ON_BOTH_SIDES') { + const custom = opt.customMessage.decline.containsItemsOnBothSides; + reply = custom ? custom : declined + ' because the offer sent contains items on both sides.'; } else { // const custom = opt.customMessage.decline.general; diff --git a/src/classes/Options.ts b/src/classes/Options.ts index 6fb7dd4d2..177cd166c 100644 --- a/src/classes/Options.ts +++ b/src/classes/Options.ts @@ -39,6 +39,9 @@ export const DEFAULTS: JsonOptions = { enable: true, withUncraft: true }, + itemsOnBothSides: { + enable: false + }, checkUses: { duel: true, noiseMaker: true @@ -631,7 +634,8 @@ export const DEFAULTS: JsonOptions = { failedToCounter: '', takingItemsWithIntentBuy: '', givingItemsWithIntentSell: '', - containsKeysOnBothSides: '' + containsKeysOnBothSides: '', + containsItemsOnBothSides: '' }, accepted: { automatic: { @@ -1213,6 +1217,7 @@ interface MiscSettings { sendGroupInvite?: OnlyEnable; skipItemsInTrade?: OnlyEnable; weaponsAsCurrency?: WeaponsAsCurrency; + itemsOnBothSides?: OnlyEnable; checkUses?: CheckUses; game?: Game; alwaysRemoveItemAttributes?: AlwaysRemoveItemAttributes; @@ -1770,6 +1775,7 @@ interface DeclineNote { takingItemsWithIntentBuy?: string; givingItemsWithIntentSell?: string; containsKeysOnBothSides?: string; + containsItemsOnBothSides?: string; } interface AcceptedNote { diff --git a/src/schemas/options-json/options.ts b/src/schemas/options-json/options.ts index 20ab7345e..277190c35 100644 --- a/src/schemas/options-json/options.ts +++ b/src/schemas/options-json/options.ts @@ -436,6 +436,16 @@ export const optionsSchema: jsonschema.Schema = { required: ['enable', 'withUncraft'], additionalProperties: false }, + itemsOnBothSides: { + type: 'object', + properties: { + enable: { + type: 'boolean' + } + }, + required: ['enable'], + additionalProperties: false + }, checkUses: { type: 'object', properties: { @@ -1869,6 +1879,9 @@ export const optionsSchema: jsonschema.Schema = { }, containsKeysOnBothSides: { type: 'string' + }, + containsItemsOnBothSides: { + type: 'string' } }, required: [ @@ -1889,7 +1902,8 @@ export const optionsSchema: jsonschema.Schema = { 'failedToCounter', 'takingItemsWithIntentBuy', 'givingItemsWithIntentSell', - 'containsKeysOnBothSides' + 'containsKeysOnBothSides', + 'containsItemsOnBothSides' ], additionalProperties: false }, From 79eb2442da0e60e9e7dfe7abed0713a3cb4ffd6e Mon Sep 17 00:00:00 2001 From: Junior <42356930+juniorISO69960@users.noreply.github.com> Date: Thu, 25 Jul 2024 17:29:41 -0500 Subject: [PATCH 3/3] changed the default for itemsOnBothSides to true --- src/classes/Options.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/classes/Options.ts b/src/classes/Options.ts index 177cd166c..c1366a77d 100644 --- a/src/classes/Options.ts +++ b/src/classes/Options.ts @@ -40,7 +40,7 @@ export const DEFAULTS: JsonOptions = { withUncraft: true }, itemsOnBothSides: { - enable: false + enable: true }, checkUses: { duel: true,