丰富嵌入中的提及显示为他们的字符串 [英] Mentions in a rich embed are appearing as their string

查看:6
本文介绍了丰富嵌入中的提及显示为他们的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个问题,即我的机器人在富嵌入中没有正确提及.它似乎根本无法标记用户.

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>

应该 ping 用户并且看起来像......

It should ping the user and look like...

<小时>

  • 我已尝试在我的消息中执行 author.toString().
  • 我尝试过使用 <@${author.id}>.
  • 我尝试过使用 @${author.tag}.
  • 我尝试过使用 ${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);
    

    我的主要目标是在嵌入消息中标记用户而不标记用户.我的主要重点是让 https://imgur.com/a/hbgm1TXhttps://imgur.com/a/lB1Moh9 但 ping 实际上并不 ping 嵌入中的任何人.

    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.

    推荐答案

    RichEmbeds (v11) 和 MessageEmbeds (v12) 支持提及...

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

    • 作者
    • 标题
    • 字段名称
    • 页脚

    这些甚至不支持任何降价...

    These don't even support any markdown...

    • 作者
    • 页脚

    由于页脚无法解析提及,它显示为您看到的字符串.此外,用户在嵌入的任何部分都不会收到通知.最后,TextChannel#sendEmbed() 方法已弃用,并已在 Discord.js 的 v12 中删除;使用 TextChannel#send().

    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().

    此代码将使用作者的标签,而不是尝试解析页脚中的提及.如果您想在不 ping 用户的情况下使用用户的提及,可以将其放置在上面未列出的嵌入的任何部分.否则,他们的提及必须是消息内容的一部分.

    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);
    

    这篇关于丰富嵌入中的提及显示为他们的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆