discord.py - 在discord py的嵌入消息中发送带有用户标签的随机gif
问题描述
我试图在嵌入消息中发送带有用户提及的随机 gif,用户标签很好,但 gif 不会显示在嵌入消息中。这是消息的屏幕截图。
也是命令的代码
@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)
我已经看到了很多与此类似的问题,但是对于随机消息没有一个答案,并且当我在这些问题中使用它们的固定代码时,该命令不起作用。谢谢你。
解决方案
只是将链接放在嵌入的描述中不会呈现它。您需要将其设置为图像。
@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)
推荐阅读
- r - 在 data.table 构造函数中使用“key”作为列名
- r - R - ggplot2 - 提取两条线之间的点
- excel - 我想调用内部网站上的特定功能
- json - 读/写本地json文件swift 4
- java - 11111111111111111111111111111110 如何评估为-2?
- javascript - javascript if 语句返回值
- php - 最近 5 天之前的付款待处理通知显示 Php mysqli
- ios - iOS Core蓝牙无法通过特性传输数据
- c# - 从句柄渲染 Windows 中控件的图像
- scala - TestProbe 没有收到来自 RouteSpec 的消息