dadbot
dadbot copied to clipboard
Exclude Embed URLs from Auto Responce Matching
This may be a minor nitpick but the auto-response can trigger on words that are part of an embed URL. For example, the "Goodbye matcher" triggers on this URL https://tenor.com/view/frank-sinatra-anchors-aweigh-hi-bye-see-ya-gif-13047761 which contains the word "bye".
It might make sense to stripe embed URLs from message contents before running it through the regexes for auto-responses to prevent the dad bot from triggering on seemingly text-free messages with just an image or other types of embed.
A possible solution is to iterate through the message object's "embeds" field and remove their URLs from the message's contents. (Code snippet inserted at line 56 of AutoResponce.ts)
if ("embeds" in msg) {
msg.embeds.forEach((embed) => {
if ("url" in embed) {
msg.content = msg.content.replace(embed.url, "");
}
});
}
Another option would be to use a URL-detecting regex to remove URLs from the message's contents, although URLs are complicated, and finding a good Regex for it is non-trivial.