【问题标题】:Sending random gif with user tag inside embed message in discord py在discord py的嵌入消息中发送带有用户标签的随机gif
【发布时间】:2021-06-27 20:26:45
【问题描述】:

我试图在嵌入消息中发送带有用户提及的随机 gif,用户标签很好,但 gif 不会显示在嵌入消息中。这是消息的screenshot。

这里也是命令的代码

@client.command()
async def slap(ctx, user: discord.Member):
    randomgifs = [
    discord.Embed(title = "", description = f'{ctx.author.mention} has slapped {user.mention}\n\nhttps://i.imgur.com/8KfHd8m.gif', color = ctx.author.color), 
    discord.Embed(title = "", description = f'{ctx.author.mention} has slapped {user.mention}\n\nhttps://i.imgur.com/AAUukQd.gif', color = ctx.author.color),
    discord.Embed(title = "", description = f'{ctx.author.mention} has slapped {user.mention}\n\nhttps://i.imgur.com/ZDiDDdc.gif', color = ctx.author.color),
    discord.Embed(title = "", description = f'{ctx.author.mention} has slapped {user.mention}\n\nhttps://i.imgur.com/28BGRwI.gif', color = ctx.author.color),
    discord.Embed(title = "", description = f'{ctx.author.mention} has slapped {user.mention}\n\nhttps://i.imgur.com/HqHljrw.gif', color = ctx.author.color)]
    randomitem = random.choice(randomgifs)
    await ctx.send(embed=randomitem)

我已经看到了很多与此类似的问题,但是对于随机消息没有一个答案,并且当我在这些问题中使用它们的固定代码时,该命令不起作用。谢谢。

【问题讨论】:

    标签: discord.py


    【解决方案1】:

    仅将链接放在嵌入的描述中不会呈现它。您需要将其设置为image。

    @client.command()
    async def slap(ctx, user: discord.Member):
        randomgifs = [
            "https://i.imgur.com/8KfHd8m.gif",
            "https://i.imgur.com/AAUukQd.gif",
            "https://i.imgur.com/ZDiDDdc.gif",
            "https://i.imgur.com/28BGRwI.gif",
            "https://i.imgur.com/HqHljrw.gif"
        ]
        
        embed = discord.Embed(
            title = "",
            description = f"{ctx.author.mention} has slapped {user.mention}",
            color = ctx.author.color
        )
    
        randomgif = random.choice(randomgifs)
        embed.set_image(url = randomgif)
        await ctx.send(embed = embed)
    

    【讨论】:

      猜你喜欢
      • 2021-09-15
      • 2021-06-05
      • 2021-08-19
      • 2021-12-21
      • 2019-10-02
      • 2021-05-23
      • 2020-04-07
      • 2021-06-17
      • 1970-01-01
      相关资源
      最近更新 更多