I'm making a pls search type of command, but I don't know how to make the bot say something like "You found [random amount of coins from 50 - 3000] coins!" after i type the answer to a question. I also don't know how to make it so that the 3 [random_place]s are not the same. So basically I want the bot to do this:
me: pls search
bot: "Where do you want to search? [random_place#1], [random_place#2], [random_place#3]"
me: [random_place#1]
bot: "You found [random amount of coins from 50 - 3000] coins!"
I tried using a @client.event inside the @client.command using on_message, but then when I tried to test it out, I was able to spam the answer and get infinite coins. How do I fix this? This is my code:
@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}`")
@client.event
async def on_message(message):
if message.author == client.user:
return
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}')
question from:https://stackoverflow.com/questions/65622961/how-do-you-stop-make-a-discord-bot-ask-something-and-then-when-i-type-something