Skip to content

Commit

Permalink
fix: NoEmbed url detection
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart committed May 7, 2023
1 parent 4c1bffb commit 269060a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/NoEmbed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ export interface NoEmbedOptions {
readonly topicKeyword: string
}

const UrlRE =
/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/

const make = ({ topicKeyword }: NoEmbedOptions) =>
Effect.gen(function* (_) {
const gateway = yield* _(DiscordGateway)
Expand All @@ -36,7 +33,10 @@ const make = ({ topicKeyword }: NoEmbedOptions) =>
() => new NotValidMessageError({ reason: "disabled" }),
),
Effect.filterOrFail(
() => UrlRE.test(message.content) && message.embeds.length > 0,
() =>
message.embeds.length > 0 &&
!!message.embeds[0].url &&
message.content.includes(message.embeds[0].url),
() => new NotValidMessageError({ reason: "no-embed" }),
),
Effect.zipRight(
Expand Down

0 comments on commit 269060a

Please sign in to comment.