Skip to content
Merged
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
2 changes: 0 additions & 2 deletions src/common/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { createShowcaseCommand } from '@/features/showcase/create-showcase.js';
import { sendShowcasePinnedMessage } from '@/features/showcase/send-pinned-message.js';
import { tipsCommands } from '@/features/tips/index.js';
import type { Command } from './types.js';
import { showcaseTempRestructureCommand } from '@/features/showcase/temp-restructure.js';

export const commands = new Map<string, Command>(
[
Expand All @@ -21,7 +20,6 @@ export const commands = new Map<string, Command>(
publicGuidesCommand,
createShowcaseCommand,
sendShowcasePinnedMessage,
showcaseTempRestructureCommand,
]
.flat()
.map((command) => [command.data.name, command])
Expand Down
101 changes: 0 additions & 101 deletions src/features/showcase/temp-restructure.ts

This file was deleted.

30 changes: 9 additions & 21 deletions src/features/showcase/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,21 @@ export type ShowcaseMessageData = {
authorId: string;
};

export const parseShowcaseMessage = (content: string): ShowcaseMessageData => {
const isOldStructure = content.startsWith('## Project Name:');
if (isOldStructure) {
const [header = '', ...descriptionParts] = content.split(/\n\n+/);
const headerLines = header.split('\n');
const FOOTER_REGEX = /\n+\*\*Author:\*\* <@(\d+)>(?:\n\*\*Link:\*\* (.+))?\s*$/;

const authorLine = headerLines.find((line) =>
line.startsWith('**Author:** ')
);
const authorId = authorLine?.match(/<@(\d+)>/)?.[1] ?? '';
const linkLine = headerLines.find((line) => line.startsWith('**Link:** '));
const link = linkLine?.replace(/^\*\*Link:\*\*\s*/, '') ?? '';
const description = descriptionParts.join('\n\n').trim();
export const parseShowcaseMessage = (content: string): ShowcaseMessageData => {
const footerMatch = content.match(FOOTER_REGEX);

return { link, description, authorId };
if (!footerMatch) {
return { authorId: '', link: '', description: content.trim() };
}

const authorMatch = content.match(/\*\*Author:\*\* <@(\d+)>/);
const linkMatch = content.match(/\*\*Link:\*\* (.+)/);
const description = content
.replace(/\*\*Author:\*\* <@\d+>/, '')
.replace(/\*\*Link:\*\* .+/, '')
.trim();
const [, authorId, link] = footerMatch;
const description = content.slice(0, footerMatch.index).trim();

return {
authorId: authorMatch?.[1] ?? '',
link: linkMatch?.[1] ?? '',
authorId: authorId ?? '',
link: link?.trim() ?? '',
description,
};
};
Expand Down
Loading