2 回答
TA贡献1816条经验 获得超4个赞
只需在 def 中添加另一个参数即可:
@bot.command()
async def eat(ctx, what:str=''):
if what == apple:
print("You ate an apple!")
elif what == cake:
print("You ate Cake!")
elif what == cookie:
print("You ate a Cookie!")
else:
print("Sorry I don't know that food in there. Please try again")
TA贡献1856条经验 获得超11个赞
使用wait_for
,您可以等待用户回复消息并根据他们的回复执行某些操作。
@bot.command()
async def eat(ctx):
await ctx.send('What would you like to eat? Apple, Cake, or Cookie?')
msg = await bot.wait_for('message')
if msg.content == 'Apple'.lower():
await ctx.send('You ate an apple!')
elif msg.content == 'Cake'.lower():
await ctx.send('You ate Cake!')
elif msg.content == 'Cookie'.lower():
await ctx.send('You ate a Cookie!')
else:
await ctx.send('Sorry I don\'t know that food in there. Please try again')
添加回答
举报