如何通过编辑从嵌入中删除字段? [英] How can I remove a field from an embed by editing it?

查看:33
本文介绍了如何通过编辑从嵌入中删除字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,假设我创建了一个嵌入并将其发送到频道.这是嵌入的内容:

So let's say I create an embed and sent it to a channel. Here's the embed:

const embed = new Discord.RichEmbed()
        .setColor(color)
        .setTitle(`${message.author.tag} wants to play.`)
        .setAuthor(message.author.tag, message.author.displayAvatarURL)
        .setDescription(game)
        .setThumbnail(icon)
        .addField(`\u200b\n**React with ${emoji} to join.**`, "Remove your reaction to leave.");

发送后,我要编辑该嵌入的标题和说明,并删除我最后添加的字段.

Once it's sent, I want to edit that embed's title and description and delete the field I added at the end.

这是我要创建的新嵌入内容:

Here's the new embed I'm trying to create:

const embed = new Discord.RichEmbed(reaction.message.embeds[0])
            .setTitle("This game has ended.")
            .setDescription("You can no longer join.");

这会更改标题和描述,但是我不确定如何删除自己添加的字段.

This changes the title and description but I'm unsure on how to remove the field that I added too.

推荐答案

我知道这已经有6个月了,但是如果有人像我一样绊倒在这里,则不应将embed.fields设置为null.这样可以防止以后使用addField方法添加新字段.而是将其设置为空数组.

I know this is 6 months old, but in case anyone else stumbles here like I did you should not set embed.fields to null. This prevents new fields from being added later using the addField method. Instead set it to an empty array.

embed.fields = [];

这篇关于如何通过编辑从嵌入中删除字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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