Your on_message would be global and throughout the whole bot when running, this means if anyone says those specific keywords, they would get coins even when the command is not running.
You also cannot have an event used in a command like you have used, simply use a check as shown below:
message = await client.wait_for('message', timeout=10, check=lambda message: message.author == ctx.author)
if message.content.startswith(f'{a}'):
await message.channel.send(f'{a.value}')
if message.content.startswith(f'{b}'):
await message.channel.send(f'{b.value}')
if message.content.startswith(f'{c}'):
await message.channel.send(f'{c.value}')
Simply change this to how you wanted it, hope this helps!
@client.command()
async def search(ctx):
search_list = {
"Sewer": f'You searched the sewer and found {amount_of_coins_found} coins!',
'Area51': f'You raided Area51 and found {amount_of_coins_found} coins! NOW RUN THE GOVERNMENT IS CHASING YOU!',
'Tree': f'You climbed the tree and found {amount_of_coins_found} coins! Good thing you didn't fall off and break your neck.',
'Dog': f'You pet the dog and found {amount_of_coins_found} coins! That poor poor dog...',
'Street': f'You searched the street and found {amount_of_coins_found} coins! Good thing you didn't get run over by a bus!',
'Hospital': f'You searched the hospital and found {amount_of_coins_found} coins! Did you steal from a sick person?!',
'Dumpster': f'You climbed inside the dumpster and found {amount_of_coins_found} coins! Good thing the garbage truck only comes on Thursdays.',
'Air': f'You searched the air and found {amount_of_coins_found} coins!',
'Attic': f'You searched the attic and found {amount_of_coins_found} coins!',
'Bank': f'',
'Bed': f'',
'Bus': f'',
'Bushes': f'',
'Uber': f'',
'Car': f'',
'Coat': f'',
'Couch': f'',
'Discord': f'',
'Dresser': f'',
'Laundromat': f'',
'Mailbox': f'',
'Pocket': f'',
'Purse': f'',
'Grass': f'',
'Pantry': f'',
'Shoe': f'',
'Sink': f'',
'Pumpkin': f''
}
a = random.choice(list(search_list.keys()))
b = random.choice(list(search_list.keys()))
c = random.choice(list(search_list.keys()))
sameness = True
while sameness == True:
a = random.choice(list(search_list.keys()))
b = random.choice(list(search_list.keys()))
c = random.choice(list(search_list.keys()))
if a != b or a != c or b != c:
sameness=False
await ctx.send(f"<@{ctx.author.id}> Where do you want to search?
Pick from the list below and type it in the chat:
`{a}`, `{b}`, `{c}`")
message = await client.wait_for('message', timeout=10, check=lambda message: message.author == ctx.author)
if message.content.startswith(f'{a}'):
await message.channel.send(f'{a.value}')
if message.content.startswith(f'{b}'):
await message.channel.send(f'{b.value}')
if message.content.startswith(f'{c}'):
await message.channel.send(f'{c.value}')
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…