【问题标题】:Coinflip Embed Command Discord.py?Coinflip 嵌入命令 Discord.py?
【发布时间】:2021-06-04 17:23:12
【问题描述】:
我将如何制作一个硬币翻转嵌入命令。
我想要它做的是嵌入一个不和谐的内容,上面写着 Coinflip | (机器人名称) 作为标题,然后字段是“(使用命令的用户)硬币落在(它落在什么上面)!然后缩略图是一个硬币在反面或正面翻转的图片.
【问题讨论】:
标签:
python
discord
discord.py
【解决方案1】:
方法
您可以从随机导入选择,并使用数字 1 和 0 来确定您的硬币翻转,方法是执行 if random.choice(number) == 1: 之类的操作。
示例
import random
from random import choice
determine_flip = [1, 0]
@bot.commands()
async def coinflip(ctx):
if random.choice(determine_flip) == 1:
embed = discord.Embed(title="Coinflip | (Bot Name)", description=f"{ctx.author.mention} Flipped coin, we got **Heads**!")
await ctx.send(embed=embed)
else:
embed = discord.Embed(title="Coinflip | (Bot Name)", description=f"{ctx.author.mention} Flipped coin, we got **Tails**!")
await ctx.send(embed=embed)
结论
我希望这对您有所帮助,祝您的 Discord Bot 好运,如果您是 discord.py 的新手,那么您可以从我的社区获得帮助并改进您的 bot,甚至解决您的问题。
祝你有美好的一天!
如果您需要帮助,请加入 Discord.py For Beginners。 ;)
【解决方案2】:
async def _coinflipl(ctx):
responses = ['heads.',
'tails.']
await ctx.send(f"{random.choice(responses)}") ```