Skip to content
Merged
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
17 changes: 14 additions & 3 deletions src/features/auctions/auction-finished-reaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { redisClient } from "../../redis/client";

const code = "```";
const finishedEmojis = ["✅", "🏦"];
const allEmojis = [...finishedEmojis, "🔒"];

export const tryAuctionFinishedReactionAction = (
reaction: MessageReaction | PartialMessageReaction,
Expand Down Expand Up @@ -133,12 +134,13 @@ class AuctionFinishedReactionAction extends ReactionAction {
}
const openDkpRaidId = Number.parseInt(openDkpRaidIdStr, 10);



// add item to raid
await openDkpService.addItem(
character.Name,
item,
`Auction - ${
this.message.thread?.name || item
`Auction - ${item || this.getCleanThreadName(this.message.thread?.name || "")
} - ${this.message.createdAt.toDateString()}`,
price,
openDkpRaidId
Expand Down Expand Up @@ -198,7 +200,7 @@ ${this.example}`);
const lastHyphenIndex = threadName.lastIndexOf(" - ");
return lastHyphenIndex !== -1
? threadName.substring(lastHyphenIndex + 3) // +3 to skip the " - " itself
: threadName;
: this.getCleanThreadName(threadName);
}

private getPrice(unparsedPrice: string) {
Expand Down Expand Up @@ -227,4 +229,13 @@ ${this.example}`
private get example() {
return `${code}Example: "3 Potatus"${code}`;
}

getCleanThreadName(threadName: string): string {
function escapeRegExp(str: string): string {
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
}
const emojiPattern = new RegExp(allEmojis.map(escapeRegExp).join('|'), 'gu');
const cleanedName = threadName.replace(emojiPattern, '').trim();
return cleanedName;
}
}
Loading