Embed titles, field names, field values etc. are restricted too much when containing emoji due to JavaScript's Unicode nonsense.
The following code generates an error:
message.channel.send( new Discord.RichEmbed().setTitle(`馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃馃`) )
=> RangeError: RichEmbed titles may not exceed 256 characters.
However, because Discord API doesn't consider 馃 as 2 characters, the title is still valid, since it is 256 emoji. The same embed can be sent as an object without error:
message.channel.send({ embed: { title: `馃馃馃馃馃馃...you get the point` }})
There are probably compatibility issues with doing so, but it seems to me you could replace all statements like:
if (title.length > 256) throw new RangeError('EMBED_TITLE');
with their equivalents of:
if (Array.from(title).length > 256) throw new RangeError('EMBED_TITLE');.
Further details:
cc @Lewdcario we should just remove the checks on our side, they're kinda pointless since the api will catch them for us
Most helpful comment
cc @Lewdcario we should just remove the checks on our side, they're kinda pointless since the api will catch them for us