I have a issue that I need help. I created a bot that takes input from Discord Users and runs it to analyze for some calculations. These calculations takes 40-50 seconds usually and return the result as a reply in Discord. So far everything is fine.
But when other users or same user types another words in Discord while the previous one is in progress (calculation), the new one doesn't start to get calculated until the previous one gets done. I want the new one starts while the previous one is in progress. How can I edit this to make it right? Illuminate me. Thanks.
import discord
from threading import Thread
import asyncio
client = discord.Client()
async def init():
loop = asyncio.get_event_loop()
loop.create_task(client.start('TOKEN'))
await Thread(target=loop.run_forever).start()
@client.event
async def on_ready():
print("we've logged in as {0.user}".format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('!'):
try:
#calculation codes
await message.reply("calculation results")
except:
await message.reply("bla bla bla")