【发布时间】:2021-05-05 04:02:37
【问题描述】:
我正在尝试使用随机答案生成器制作一个 8ball 命令,但我想添加一个事件,如果您只说“&8ball”,它会说“8ball 需要一个问题”
这是我使用的代码:
@client.command(aliases=['8b','8B','8Ball','b','B','8ball','Ball'])
@cooldown(1, 7, BucketType.user)
async def ball(ctx, *, question):
embed = discord.Embed(title="????shaking the magic 8ball", colour=ctx.author.colour)
responses = [line.strip() for line in open('8ball.txt')]
choices = random.choice(responses)
embed2 = discord.Embed(title="????the magic 8ball says " + choices, colour=ctx.author.colour)
message = await ctx.send(embed=embed)
await asyncio.sleep(5)
await message.edit(embed=embed2)
这是我要添加的内容:
embed3 = discord.Embed(title="????The magic 8ball requires a question", colour=ctx.author.colour)
embed.add_field(text="Brody Foxx")
await ctx.send(embed=embed3)
我也尝试使用 if 和 else 语句
if question in message.content:
类似的东西,试着在谷歌和 YouTube 上找遍了,我要么找不到任何东西,要么它们都在 python 中重写,所以我(再一次)求助于堆栈溢出。谢谢你的帮助,如果你帮助了我,谢谢。
【问题讨论】:
标签: python python-3.x discord discord.py