Discord-MusicBot
Discord-MusicBot copied to clipboard
[v5] Not escaping formatting characters from youtube titles in various places
Please describe the problem you are having in as much detail as possible:
Video titles are not escaped when sent to discord, can result in having unintented formatting. The most common being where music videos have things like || Lyrics || in their title which discord registers as a spoiler.
See images: https://imgur.com/a/APYW7Ri (uploading them here wasn't working for some reason)
Possible Fixes:
Go along all the places it uses the text, description etc. and add in the already made:
const escapeMarkdown = require('discord.js').Util.escapeMarkdown;
to be used something like this:
.setDescription(`[${ escapeMarkdown(song.title) }](${ song.uri })`);
WARNING: THIS DOES NOT FIX THE FINAL IMAGE WHERE YOU CAN CHANGE THE LINK YOU WILL NEED TO FIX THAT YOURSELVES HOWEVER I JUST THOUGHT THESE FUNCTIONS WOULD BE A GOOD START
Explanation of editing link
To alter the link, this is the title I used:
Clicking on this will rickroll you](https://youtu.be/dQw4w9WgXcQ)[
This can be easily understood by looking at the setDesciption line above. We just change the url and close it ourselves, then make an empty one just to clean up after ourselves for no hanging characters
Essentials:
- Bot Version: v5
- Commit Hash: 1d1f172
- Node.js version: v17.9.1
- Operating system: Linux (ubuntu)
Additional system info
I doubt you will need these for this but:
- Is it virtualized? (Docker or ...) : Docker
- What CPU is it running on (X86 or ARM or...): ARM
- Additional details that might help us figure out the problem:
Relevant client options:
n/a
Can't you just do
.replace("||", "");
?
That only would only fix the spoiler one, the discordjs escape markdown would just do all of it, may as well use that instead
Of course that would also not fix the link modifying