搜索命令未按预期工作| discord.py
我不熟悉经济命令,但我仍在研究如何使用搜索命令未按预期工作| discord.py,discord.py,Discord.py,我不熟悉经济命令,但我仍在研究如何使用bot。请等待,如果这是一个简单的解决方法,我很抱歉。所以我在做一个搜索命令,但是它不起作用。即使使用代码块键入我想搜索的位置,机器人仍然无法工作 这是密码 @commands.command() async def search(self, ctx): await open_account(ctx.author) place = [f'`couch`', f"`park`", f"`road`&quo
bot。请等待,如果这是一个简单的解决方法,我很抱歉。所以我在做一个搜索命令,但是它不起作用。即使使用代码块键入我想搜索的位置,机器人仍然无法工作
这是密码
@commands.command()
async def search(self, ctx):
await open_account(ctx.author)
place = [f'`couch`', f"`park`", f"`road`"]
place1 = [f"`dog`", f"`tree`", "`car`"]
place2 = [f"`discord`", f"`grass`", f"`pocket`"]
await ctx.send(f"Where do you wanna search? Pick from the list below.\n {random.choice(place)},{random.choice(place1)}, {random.choice(place2)}")
answer = await self.bot.wait_for('message', check=lambda message: message.author == ctx.author)
if answer.content.lower() == place or answer.content == place1 or answer.content == place2:
earnings = random.randrange(301)
await update_bank(ctx.author, earnings, "wallet")
await ctx.send(f"You just found {earnings} coins. Cool")
return
else:
await ctx.send("Thats not a part of the list tho?")
你的if语句就是问题所在。你正在检查输入的单词是否与列表中的一个相等。您应该列出可用单词,然后检查给定单词是否在该列表中:
@client.command()
async def search(ctx):
place1 = ["couch", "park", "road"]
place2 = ["dog", "tree", "car"]
place3 = ["discord", "grass", "pocket"]
places = [random.choice(place1), random.choice(place2), random.choice(place3)]
placesToSearch = ', '.join([f"`{x.title()}`" for x in places])
await ctx.send(f"Where do you wanna search? Pick from the list below.\n {placesToSearch}")
response = await client.wait_for('message', check=lambda message: message.author == ctx.author)
if response.content.lower() in places:
earnings = random.randrange(301)
await ctx.send(f"You just found {earnings} coins. Cool")
else:
await ctx.send("Thats not a part of the list tho?")