我试图使用随机答案生成器生成一个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重写的,所以我(再次)求助于堆栈溢出。谢谢你的帮助,如果你帮了我的话,谢谢
Use error handler checking是错误isinstance of
commands.MissingRequiredArgument
,字段需要名称和值,而不仅仅是名称你可能想要一个页脚
您只需添加
None
即可,如果无法传递需求,则可以按如下方式使用:相关问题 更多 >
编程相关推荐