title: How to send the right file with discord
body: <p>I am building a bot that sends a txt file based on a command.
  Problem is that when two people send the same command at the same time, the bot only sends one of the two twice, which is something I should avoid at all costs.</p>
  <p>Do you have any solutions?
  I tried to come up with a solution but it didn't work: I tried to delete the file right after it has been sent, but as I said, it didn't work.</p>
  <p>NOTE: the bot successfully sends two embeds with the correct information, but then sends two identical files (always the one generated by the second request)</p>
  <p>Here's the code of the command:</p>
  <pre><code>@bot.command(name='sendfile', help='Sends a file', pass_context=True)
  async def quick(ctx, *args):
      try:
          arg1 = str(args[0]) 
          arg2 = args[1].capitalize()
          arg3  = args[2].upper()
          quantity = args[3]
          generate_file(order_id, arg2, quantity)
      
      except:
          embed = Embed(title=&quot;FILE GENERATION&quot;, description=&quot;An error has occurred. Please retry&quot;, color=16711702)
          fields = [(&quot;Error ID&quot;, &quot;1&quot;, False)]
          for name, value, inline in fields:
              embed.add_field(name=name, value=value, inline=inline)
          
          print(f&quot;{bcolors.FAIL} [{datetime.now()}] - ERROR {bcolors.ENDC}&quot;)
          raise TypeError
          
      
      
      embed = Embed(title=&quot;FILE GENERATION&quot;, description=&quot;FILE DETAILS&quot;, color=15859711)
      fields = [(&quot;ARG 1&quot;, f&quot;{arg1}&quot;, False), (&quot;Arg2&quot;, f&quot;{arg2}&quot;, False), (&quot;arg3&quot;, f'{arg3}',False), (&quot;Quantity&quot;, f&quot;{quantity}&quot;, False)]
      
      for name, value, inline in fields:
          embed.add_field(name=name, value=value, inline=inline)
      await ctx.send(embed=embed)
      print(f&quot;{bcolors.OKCYAN} [{datetime.now()}] - Command successfully executed! {bcolors.ENDC}&quot;)
      with open(&quot;generated_file.txt&quot;, &quot;rb&quot;) as file:
          await ctx.send(file=discord.File(file, &quot;generated_file.txt&quot;))
  </code></pre>
  <p>Thanks for your help :)</p>