Skip to content

Commit

Permalink
minor fix to embed fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
DownloadableFox committed Aug 6, 2024
1 parent c4f3f85 commit 526f579
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion modules/extra/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func HandleOnReadyEvent(ctx context.Context, s *discordgo.Session, e *discordgo.
}

var (
TwitterLinkRegex = regexp.MustCompile(`(https?://)?(www\.)?(twitter|x)\.com/([a-zA-Z0-9_]+/status/[0-9]+)`)
TwitterLinkRegex = regexp.MustCompile(`^(https?://)?(www\.)?(twitter|x)\.com/([a-zA-Z0-9_]+/status/[0-9]+)`)
)

// Event that catches a twitter/x link and fixes it with the correct content.
Expand Down Expand Up @@ -56,6 +56,15 @@ func HandleTwitterLinkEvent(_ context.Context, s *discordgo.Session, e *discordg
linksStr += fmt.Sprintf("https://vxtwitter.com/%s\n", link)
}

// Remove attachments from reference
if _, err := s.ChannelMessageEditComplex(&discordgo.MessageEdit{
Channel: e.ChannelID,
ID: e.ID,
Flags: e.Flags | discordgo.MessageFlagsSuppressEmbeds,
}); err != nil {
return err
}

_, err := s.ChannelMessageSendReply(e.ChannelID, fmt.Sprintf("I have fixed the Twitter embeds for you ;3\n%s", linksStr), e.Reference())
return err
}

0 comments on commit 526f579

Please sign in to comment.