Skip to content
Draft
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
5 changes: 3 additions & 2 deletions src/classes/DiscordWebhook/sendOfferReview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ export default function sendOfferReview(
): void {
const opt = bot.options.discordWebhook;

// TODO: APPLY MENTIONS ON OTHER REASONS
let noMentionOnInvalidValue = false;
if (!opt.offerReview.mentionInvalidValue) {
if (!opt.offerReview.mentions.invalidValue) {
noMentionOnInvalidValue =
reasons.includes('🟥_INVALID_VALUE') &&
!(
Expand All @@ -37,7 +38,7 @@ export default function sendOfferReview(
noMentionOnInvalidValue && !reasons.includes('⬜_REVIEW_FORCED')
? `${offer.id}`
: `${
opt.offerReview.isMention && opt.ownerID.length > 0
opt.offerReview.mentions.enable && opt.ownerID.length > 0
? opt.ownerID.map(id => `<@!${id}>`).join(', ') + `, `
: ''
}check this! - ${offer.id}`;
Expand Down
56 changes: 52 additions & 4 deletions src/classes/Options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,8 +544,19 @@ export const DEFAULTS: JsonOptions = {
offerReview: {
enable: true,
url: '',
mentionInvalidValue: true,
isMention: true,
mentions: {
enable: true,
invalidValue: false,
invalidItems: true,
overstocked: true,
understocked: true,
duped: true,
dupedCheckFailed: true,
escrowCheckFailed: true,
bannedCheckFailed: true,
halted: true,
reviewForced: true
},
misc: {
showQuickLinks: true,
showKeyRate: true,
Expand Down Expand Up @@ -1668,11 +1679,24 @@ interface MentionOwner extends OnlyEnable {

interface OfferReviewDW extends OnlyEnable {
url?: string;
mentionInvalidValue?: boolean;
isMention?: boolean;
mentions?: ReviewMentions;
misc?: MiscOfferReview;
}

interface ReviewMentions {
enable: boolean;
invalidValue: boolean;
invalidItems: boolean;
overstocked: boolean;
understocked: boolean;
duped: boolean;
dupedCheckFailed: boolean;
escrowCheckFailed: boolean;
bannedCheckFailed: boolean;
halted: boolean;
reviewForced: boolean;
}

interface MiscOfferReview {
showQuickLinks?: boolean;
showKeyRate?: boolean;
Expand Down Expand Up @@ -2476,6 +2500,30 @@ function replaceOldProperties(options: DeprecatedJsonOptions): boolean {
isChanged = true;
}

// <=v5.8.4 -> v5.9.0
/*eslint-disable */
//@ts-ignore
if (options.discordWebhook?.offerReview?.isMention) {
//@ts-ignore
options.discordWebhook.offerReview.mentions.enable = options.discordWebhook.offerReview.isMention;
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
delete options.discordWebhook.offerReview.isMention;
isChanged = true;
}

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
if (options.discordWebhook?.offerReview?.mentionInvalidValue) {
options.discordWebhook.offerReview.mentions.invalidValue = //@ts-ignore
options.discordWebhook.offerReview.mentionInvalidValue;
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
delete options.discordWebhook.offerReview.mentionInvalidValue;
isChanged = true;
}
/*eslint-enable */

return isChanged;
}

Expand Down
58 changes: 52 additions & 6 deletions src/schemas/options-json/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1646,11 +1646,57 @@ export const optionsSchema: jsonschema.Schema = {
type: 'string',
pattern: '^$|https://discord(app)?.com/api/webhooks/[0-9]+/(.)+'
},
mentionInvalidValue: {
type: 'boolean'
},
isMention: {
type: 'boolean'
mentions: {
type: 'object',
properties: {
enable: {
type: 'boolean'
},
invalidValue: {
type: 'boolean'
},
invalidItems: {
type: 'boolean'
},
overstocked: {
type: 'boolean'
},
understocked: {
type: 'boolean'
},
duped: {
type: 'boolean'
},
dupedCheckFailed: {
type: 'boolean'
},
escrowCheckFailed: {
type: 'boolean'
},
bannedCheckFailed: {
type: 'boolean'
},
halted: {
type: 'boolean'
},
reviewForced: {
type: 'boolean'
}
},
required: [
'enable',
'invalidValue',
'invalidItems',
'overstocked',
'understocked',
'duped',
'dupedCheckFailed',
'escrowCheckFailed',
'bannedCheckFailed',
'halted',
'reviewForced'
],
additionalProperties: false
},
misc: {
type: 'object',
Expand All @@ -1672,7 +1718,7 @@ export const optionsSchema: jsonschema.Schema = {
additionalProperties: false
}
},
required: ['enable', 'url', 'mentionInvalidValue', 'isMention', 'misc'],
required: ['enable', 'url', 'mentions', 'misc'],
additionalProperties: false
},
messages: {
Expand Down