Skip to content

Commit c084063

Browse files
authored
🔀 Merge pull request #1781 from juniorISO69960/master
Add an option for denying trades with items on both sides of the trade.
2 parents 06dd5a0 + 79eb244 commit c084063

File tree

5 files changed

+40
-3
lines changed

5 files changed

+40
-3
lines changed

src/classes/DiscordWebhook/sendTradeDeclined.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export default async function sendTradeDeclined(
7171
const declinedDescription = declined.reasonDescription;
7272
const declinedTradeSummary: Webhook = {
7373
username: optDW.displayName || botInfo.name,
74-
avatar_url: optDW.avatarURL || optDW.avatarURL,
74+
avatar_url: optDW.avatarURL || botInfo.avatarURL,
7575
content: '',
7676
embeds: [
7777
{

src/classes/MyHandler/MyHandler.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,20 @@ export default class MyHandler extends Handler {
761761
};
762762
}
763763

764+
// Check if the offer has items on both sides
765+
if (
766+
!opt.miscSettings.itemsOnBothSides.enable &&
767+
exchange['our'].contains.items &&
768+
exchange['their'].contains.items
769+
) {
770+
offer.log('info', 'offer has items on both sides');
771+
return {
772+
action: 'decline',
773+
reason: 'CONTAINS_ITEMS_ON_BOTH_SIDES',
774+
meta: isContainsHighValue ? { highValue: highValueMeta } : undefined
775+
};
776+
}
777+
764778
const itemsToGiveCount = offer.itemsToGive.length;
765779
const itemsToReceiveCount = offer.itemsToReceive.length;
766780

src/classes/MyHandler/offer/notify/declined.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,9 @@ export default function declined(offer: TradeOffer, bot: Bot): void {
217217
reply = custom
218218
? custom
219219
: declined + ' because the offer sent contains Mann Co. Supply Crate Key on both sides.';
220+
} else if (offerReason.reason === 'CONTAINS_ITEMS_ON_BOTH_SIDES') {
221+
const custom = opt.customMessage.decline.containsItemsOnBothSides;
222+
reply = custom ? custom : declined + ' because the offer sent contains items on both sides.';
220223
} else {
221224
//
222225
const custom = opt.customMessage.decline.general;

src/classes/Options.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ export const DEFAULTS: JsonOptions = {
3939
enable: true,
4040
withUncraft: true
4141
},
42+
itemsOnBothSides: {
43+
enable: true
44+
},
4245
checkUses: {
4346
duel: true,
4447
noiseMaker: true
@@ -631,7 +634,8 @@ export const DEFAULTS: JsonOptions = {
631634
failedToCounter: '',
632635
takingItemsWithIntentBuy: '',
633636
givingItemsWithIntentSell: '',
634-
containsKeysOnBothSides: ''
637+
containsKeysOnBothSides: '',
638+
containsItemsOnBothSides: ''
635639
},
636640
accepted: {
637641
automatic: {
@@ -1213,6 +1217,7 @@ interface MiscSettings {
12131217
sendGroupInvite?: OnlyEnable;
12141218
skipItemsInTrade?: OnlyEnable;
12151219
weaponsAsCurrency?: WeaponsAsCurrency;
1220+
itemsOnBothSides?: OnlyEnable;
12161221
checkUses?: CheckUses;
12171222
game?: Game;
12181223
alwaysRemoveItemAttributes?: AlwaysRemoveItemAttributes;
@@ -1770,6 +1775,7 @@ interface DeclineNote {
17701775
takingItemsWithIntentBuy?: string;
17711776
givingItemsWithIntentSell?: string;
17721777
containsKeysOnBothSides?: string;
1778+
containsItemsOnBothSides?: string;
17731779
}
17741780

17751781
interface AcceptedNote {

src/schemas/options-json/options.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,16 @@ export const optionsSchema: jsonschema.Schema = {
436436
required: ['enable', 'withUncraft'],
437437
additionalProperties: false
438438
},
439+
itemsOnBothSides: {
440+
type: 'object',
441+
properties: {
442+
enable: {
443+
type: 'boolean'
444+
}
445+
},
446+
required: ['enable'],
447+
additionalProperties: false
448+
},
439449
checkUses: {
440450
type: 'object',
441451
properties: {
@@ -1869,6 +1879,9 @@ export const optionsSchema: jsonschema.Schema = {
18691879
},
18701880
containsKeysOnBothSides: {
18711881
type: 'string'
1882+
},
1883+
containsItemsOnBothSides: {
1884+
type: 'string'
18721885
}
18731886
},
18741887
required: [
@@ -1889,7 +1902,8 @@ export const optionsSchema: jsonschema.Schema = {
18891902
'failedToCounter',
18901903
'takingItemsWithIntentBuy',
18911904
'givingItemsWithIntentSell',
1892-
'containsKeysOnBothSides'
1905+
'containsKeysOnBothSides',
1906+
'containsItemsOnBothSides'
18931907
],
18941908
additionalProperties: false
18951909
},

0 commit comments

Comments
 (0)