I want to make a discord bot in python command that starts a game in where u have to write a given word and stops once a user spells it correctly, but return
won t work in my case
async def joc(ctx):
a=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
'0','1','2','3','4','5','6','7','8','9']
cuv=random.sample(a,10)
cuvant=''
for x in cuv:
cuvant+=x
await ctx.send('The game begins in: ')
await ctx.send('3')
time.sleep(1)
await ctx.send('2')
time.sleep(1)
await ctx.send('1')
time.sleep(1)
await ctx.send('Start!')
await ctx.send(cuvant)
@bot.event
async def on_message(message):
if message.content==cuvant:
await message.channel.send(message.author)
await message.channel.send("Nice")
return
return
I can do this with accesing the history but i want to know how to do it like this
exit()
to quit, if you want it to repeat again, then you can write all of your working code inside awhile True:
loop. – shakhyar.codesbreak
at the end – shakhyar.codes