Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mentions in a rich embed are appearing as their string

Tags:

discord.js

I'm having a problem where my bot does not mention correctly in rich embeds. It appears to be unable to tag a user at all.

A mention ends up looking like...

<@601756839956447232>

It should ping the user and look like...

@StackOverflow


  • I've tried doing author.toString() in my message.
  • I've tried using <@${author.id}>.
  • I've tried using @${author.tag}.
  • I've tried using ${author}.

All of these attempts produce the same result.


This is the code I'm using...

var serv = message.guild
var author = message.author

var myInfo = new discord.RichEmbed()
    .setAuthor(`${serv.name}'s roles`,`${message.guild.iconURL}`)
    .addField(`Roles`, serv.roles.map(r => `${r}`).join(' | '),true)
    .setColor(0xffd000)
    .setFooter('Server Roles.')
    .setFooter(`Requested by @${author.tag}`,`${author.avatarURL}`)

message.channel.sendEmbed(myInfo);

My main goal here is to tag the user in the embed message without tagging the user. My main focus is to get https://imgur.com/a/hbgm1TX to https://imgur.com/a/lB1Moh9 but the ping does NOT actually ping anyone located in the embed.

like image 246
SomePerson Avatar asked Jul 19 '19 08:07

SomePerson


People also ask

Why add rich media embeds to your bit document?

An estimated 84 percent of communications will be visual by 2018. Adding rich media embeds to your Bit document allows your documents to have a visual dimension to them. The best part is you aren’t causing your audience to click on a bunch of links that open up multiple windows.

Do richembeds support mentions?

1 Answer 1 ActiveOldestVotes 13 These text-based properties of RichEmbeds (v11) and MessageEmbeds (v12) do notsupport mentions... Author Title Field Name Footer These don't even support any markdown... Author Footer Because a footer can't parse the mention, it shows up as the string you see.

How do presentation rich media embeds look and feel in bit?

Let’s look at some examples of how these presentation rich media embeds look and feel in a Bit document: If you are an avid user of SlideShare, you can embed it directly in your Bit document by simply pasting the URL of your file in your document. Here’s an example of what a SlideShare would look inside a Bit document:

Why does my mention show up as a string in footer?

Because a footer can't parse the mention, it shows up as the string you see. Also, a user will not be given a notification for their mention in any part of an embed. Finally, the TextChannel#sendEmbed()method is deprecated and has been removed in v12 of Discord.js; use TextChannel#send().


1 Answers

These text-based properties of RichEmbeds (v11) and MessageEmbeds (v12) do not support mentions...

  • Author
  • Title
  • Field Name
  • Footer

These don't even support any markdown...

  • Author
  • Footer

Because a footer can't parse the mention, it shows up as the string you see. Also, a user will not be given a notification for their mention in any part of an embed. Finally, the TextChannel#sendEmbed() method is deprecated and has been removed in v12 of Discord.js; use TextChannel#send().

This code will use the author's tag instead of trying to parse a mention in the footer. If you want to use the user's mention without pinging them, you can place it in any part of the embed not listed above. Otherwise, their mention must be part of the message content.

var myInfo = new discord.RichEmbed() // v11 only
  .setColor(...)
  .setAuthor(...)
  .addField(...)
  .setFooter(`Requested by ${message.author.tag}.`, message.author.displayAvatarURL);

message.channel.send(myInfo)
  .catch(console.error);
like image 174
slothiful Avatar answered Oct 03 '22 09:10

slothiful