Skip to content

Commit

Permalink
Adjust URL rendering of pinned message contents (#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeeus authored Dec 11, 2023
1 parent 15057cd commit 1fb4f9d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions services/bots/src/discord/commands/common/pinned.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ export class CommandCommonPinned implements DiscordTransformedCommand<any> {
description: pinned
.map(
(message) =>
`- ["${transformConetent(message.content) || 'embeded content'}"](<${
message.url
}>)`,
`- ["${transformContent(message.content) || 'embeded content'}"](<${message.url}>)`,
)
.join('\n'),
},
Expand All @@ -44,7 +42,10 @@ export class CommandCommonPinned implements DiscordTransformedCommand<any> {
}
}

const transformConetent = (content: string): string => {
const transformContent = (content: string): string => {
const base = content.replace(/\n/g, ' ');
return base.length < 64 ? base : `${base.substring(0, 64)}...`;
return (base.length < 64 ? base : `${base.substring(0, 64)}...`)
.replace(/</g, '')
.replace(/>/g, '')
.replace(/https?:\/\//g, '');
};

0 comments on commit 1fb4f9d

Please sign in to comment.