I am using regex to change my translation bot sending custom emojis. By doing this I can remove unsupported unlatin names and whitespaces:
data.text.replace(/:.*?:/, ":okthisisanemoji:");
This works fine and the translator does send custom emojis now but I want it to loop until the only thing that is inbetween any : is :okthisisanemoji: .
Right now I cant do more than one ethically because a normal loop would just replace :okthisisanemoji: forever.
Can someone help describe to me how to create a loop which replaces the string of < : translatedemojiname : emojiID> to <:okthisisanemoji:emojiID> but for every emoji sent in the message instead of only the last or first 3-4.
Code is this:
if (data.author)
{
if (data.text.includes("<:"))
// -> data.text = <: gelb:590653333124022288>
{
data.text = data.text.replace(/:.*?:/, ":okthisisanemoji:");
// -> <:okthisisanemoji:590653333124022288> ( but right now it does not do it for everything.
data.text = data.text.replace(": ", ":"); // -> "ABCDEFGHSTUVWXYZ"
data.text = data.text.replace("<: ", "<:");
}
}
The source code is here: https://github.com/Zyc0r3/RitaBot/tree/emoji
And the file is https://github.com/ZyC0R3/RitaBot/blob/emoji/src/core/send.js
It's a translation bot for Discord and right now the custom emoji is a problem. Please help
Website is here: https://ritabot.org
Discord Server is here: https://discord.gg/NAxA3nf
:
exceptokthisisanemoji
? Try/:(?!okthisisanemoji:).*?:/
– Wiktor Stribiżew