[英]How do I get a discord bot to send a random message inside an embed in python
So I wanted to use a command that puts a random message inside of an embed that also has a random gif attached to it, here is the code I'm using:所以我想使用一个命令,将随机消息放入一个嵌入中,该嵌入还附有一个随机 gif,这是我正在使用的代码:
roastgifs = [
'https://tenor.com/view/roasted-oh-shookt-gif-8269968'
]
@client.command(aliases=['Roast'])
async def roast(ctx, member : discord.Member):
global roasting
global sus
roasting = [line.strip() for line in open('jokes.txt')]
sus = random.choice(roasting)
embed=discord.Embed(title=f"{ctx.author.mention} roasts {member.mention}\n\"" + sus + "\"")
roastgif=random.choice(roastgifs)
embed.set_image(url=roastgif)
embed.set_footer("footer")
await ctx.send(embed=embed)
I can't find that many tutorials on yt and Google and even then they're probably js and not py so I resorted to coming here again.我在 yt 和 Google 上找不到那么多教程,即便如此,它们可能是 js 而不是 py,所以我再次求助于这里。
Also I would greatly appreciate how to make the bot ping someone with an ID if that's alright.另外,如果可以的话,我将非常感谢如何使机器人 ping 具有 ID 的人。
Embed.set_footer
takes only keyword arguments, and you're passing a positional argument Embed.set_footer
只接受关键字 arguments,并且您正在传递一个位置参数
embed.set_footer(text="Footer")
Also a few things:还有几点:
Embed.set_image
Embed.set_image
中添加图片
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.