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

如何修改Discord selfbot的Python命令使其发送Embed嵌入式消息

修改方案

你只需要调用discord.Embed类创建嵌入式消息对象,再把内容填充到Embed的对应字段中,最后调用ctx.send()时传入embed参数即可。

完整修改后代码(带自定义样式版)

@knife.command()
async def howgay(ctx, member: discord.Member):
    await ctx.message.delete()
    # 先生成随机数值
    gay_rate = random.randint(0, 101)
    # 初始化Embed对象,设置标题、配色
    embed = discord.Embed(
        title = "🏳️‍🌈 Gay率检测结果",
        color = discord.Color.random() # 也可指定固定颜色,比如discord.Color.blue()
    )
    # 填充检测结果到Embed内容区
    embed.add_field(
        name = "检测结果",
        value = f"{member.mention} 是 {gay_rate}% gay",
        inline = False
    )
    # 可选配置:显示被检测用户头像
    embed.set_thumbnail(url = member.avatar.url if member.avatar else member.default_avatar.url)
    # 发送Embed消息
    await ctx.send(embed = embed)

极简修改版(仅改输出为Embed无额外样式)

@knife.command()
async def howgay(ctx, member:discord.Member):
    await ctx.message.delete()
    gay_rate = random.randint(0,101)
    embed = discord.Embed(description=f"{member.mention} is {gay_rate}% gay")
    await ctx.send(embed=embed)

注意事项

  • 如果你使用的是discord.py v2.0以下的旧版本,需要把member.avatar.url替换为member.avatar_url才能正常显示用户头像
  • Embed还支持自定义页脚、作者信息等字段,可根据需求自行扩展对应属性

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.04 11:45:00