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

如何用Python实现带超链接的可点击Discord表情?

实现Discord可点击跳转的表情效果

Discord原生不支持直接给普通表情添加跳转链接,你要实现的点击表情跳转到指定网址的效果,需要用消息按钮组件来模拟。以下是修正后的代码:

import discord
from discord.ext import commands
from discord.ui import Button, View

bot = commands.Bot(command_prefix='!', description="help") 
bot.remove_command("help") 

@bot.command()
async def emojibot(ctx):
    # 创建链接按钮,用目标表情作为按钮显示内容
    emoji_link_btn = Button(
        emoji="<:HabboHotel:1023577803817492490>",
        url="https://habbo.es",
        style=discord.ButtonStyle.link
    )
    # 创建视图容器并添加按钮
    view = View()
    view.add_item(emoji_link_btn)
    # 发送带按钮的消息
    await ctx.send(view=view)

@bot.event
async def on_ready():
    print("ready")

bot.run('你的Bot令牌') 

关键说明:

  • 普通表情标签<:HabboHotel:1023577803817492490>本身不支持附加跳转链接,必须借助Discord的Button组件实现点击跳转
  • 使用discord.ButtonStyle.link类型的按钮,点击后会直接打开指定的URL,无需额外编写回调逻辑
  • 按钮的emoji参数可以直接填入你自定义表情的标准格式,实现“表情样式的可点击跳转按钮”效果

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.10 09:35:22