Skip to content

Commit

Permalink
discord formatting character replacer
Browse files Browse the repository at this point in the history
  • Loading branch information
idinium96 committed Jul 3, 2020
1 parent 7a5f41a commit 369b763
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions src/classes/DiscordWebhook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,14 +210,13 @@ export = class DiscordWebhook {
partnerName = them.personaName;
}

const partnerNameNoFormat =
partnerName.includes('_') || partnerName.includes('*') || partnerName.includes('~~')
? partnerName
.replace(/_/g, '‗')
.replace(/\*/g, '★')
.replace(/~/g, '⁓')
.replace(/`/g, '^')
: partnerName;
const partnerNameNoFormat = partnerName
.replace(/_/g, '‗')
.replace(/\*/g, '★')
.replace(/~/g, '⁓')
.replace(/`/g, '^')
.replace(/>/g, '<')
.replace(/\|/g, '!');

const isShowQuickLinks = process.env.DISCORD_WEBHOOK_REVIEW_OFFER_SHOW_QUICK_LINKS !== 'false';
const isShowKeyRate = process.env.DISCORD_WEBHOOK_REVIEW_OFFER_SHOW_KEY_RATE !== 'false';
Expand Down Expand Up @@ -252,7 +251,15 @@ export = class DiscordWebhook {
? `\n📉 ***Loss from underpay:*** ${value.diffRef} ref` +
(value.diffRef >= keyPrice.sell.metal ? ` (${value.diffKey})` : '')
: '') +
(offerMessage.length !== 0 ? `\n\n💬 Offer message: _${offerMessage}_` : '') +
(offerMessage.length !== 0
? `\n\n💬 Offer message: _${offerMessage
.replace(/_/g, '‗')
.replace(/\*/g, '★')
.replace(/~/g, '⁓')
.replace(/`/g, '^')
.replace(/>/g, '<')
.replace(/\|/g, '!')}_`
: '') +
`${
invalidItemsName.length !== 0
? `\n\n🟨INVALID_ITEMS - ${invalidItemsName.join(', ')}`
Expand Down Expand Up @@ -357,14 +364,13 @@ export = class DiscordWebhook {
avatarFull = details.avatarFull;
}

const partnerNameNoFormat =
personaName.includes('_') || personaName.includes('*') || personaName.includes('~~')
? personaName
.replace(/_/g, '‗')
.replace(/\*/g, '★')
.replace(/~/g, '⁓')
.replace(/`/g, '^')
: personaName;
const partnerNameNoFormat = personaName
.replace(/_/g, '‗')
.replace(/\*/g, '★')
.replace(/~/g, '⁓')
.replace(/`/g, '^')
.replace(/>/g, '<')
.replace(/\|/g, '!');

const isShowQuickLinks = process.env.DISCORD_WEBHOOK_TRADE_SUMMARY_SHOW_QUICK_LINKS !== 'false';
const isShowKeyRate = process.env.DISCORD_WEBHOOK_TRADE_SUMMARY_SHOW_KEY_RATE !== 'false';
Expand Down

0 comments on commit 369b763

Please sign in to comment.