You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Discord.py中如何为单个Embed添加双标题,或实现双投票链接的发送?

解决Discord机器人同时发送两个投票链接的问题

首先得明确:Discord的Embed组件只能有一个主标题,所以没法直接给同一个Embed添加第二个标题。不过有几个实用的替代方案可以实现你想要的效果,下面给你详细说明:

方案1:在单个Embed中添加两个投票字段

你可以保留一个通用的主标题,然后用add_field()方法添加两个独立字段,每个字段对应一个投票链接,既整洁又能清晰展示两个投票选项。

修改后的代码示例:

client = discord.Client()
@client.event
async def on_message(message):
    if message.content.startswith(']svote') :
        await message.add_reaction(doubleupemote)
        # 创建Embed,主标题用通用的投票提示
        embed = discord.Embed(title="支持我们:投上你的一票!", color=0x00fa11)
        # 添加服务器投票字段
        embed.add_field(
            name="为服务器投票",
            value="[点击前往投票](https://top.gg/servers/876028384042426368/vote)",
            inline=False  # 设置为False让每个字段单独占一行,提升可读性
        )
        # 添加机器人投票字段,替换成你的机器人投票链接
        embed.add_field(
            name="为机器人投票",
            value="[点击前往投票](这里替换成你的机器人投票URL)",
            inline=False
        )
        await message.channel.send(embed=embed)

方案2:发送两个独立的Embed

如果希望每个投票都有自己的专属标题,最直接的方式就是发送两个分开的Embed,每个对应一个投票项:

client = discord.Client()
@client.event
async def on_message(message):
    if message.content.startswith(']svote') :
        await message.add_reaction(doubleupemote)
        # 服务器投票Embed
        server_embed = discord.Embed(title="为服务器投票", url="https://top.gg/servers/876028384042426368/vote", color=0x00fa11)
        await message.channel.send(embed=server_embed)
        # 机器人投票Embed,替换URL为你的机器人投票链接
        bot_embed = discord.Embed(title="为机器人投票", url="这里替换成你的机器人投票URL", color=0x00fa11)
        await message.channel.send(embed=bot_embed)

方案3:直接发送带链接的文本消息(最简方案)

如果不需要Embed的美化效果,也可以直接发送包含两个投票链接的普通消息,代码更简洁:

client = discord.Client()
@client.event
async def on_message(message):
    if message.content.startswith(']svote') :
        await message.add_reaction(doubleupemote)
        vote_msg = """
快来支持我们:
- [为服务器投票](https://top.gg/servers/876028384042426368/vote)
- [为机器人投票](这里替换成你的机器人投票URL)
        """
        await message.channel.send(vote_msg)

这三个方案里,方案1兼顾美观和简洁,是比较推荐的选择;方案2视觉上更清晰,适合需要突出每个投票项的场景;方案3则适合快速实现需求的情况,你可以根据自己的服务器风格来选择~

内容的提问来源于stack exchange,提问作者Rovindu Thamuditha

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 14:49:05