title: Avoid breaking loop in discord.py
body: <p>I have discord.py robot that run in linux, and I want to modify it to only delete and send some message and go away.</p>
  
  <p>robot version goes in background (<code>fork()</code>+<code>client.run()</code>) and I stopped it using <code>kill $(&lt; file.pid)</code>
  messenger version do almost the same, but I use <code>client.close()</code> once message is send.</p>
  
  <p>the code to send message is adapted from robot, however I feel <code>client.run()/client.close()</code> is a poor choice.</p>
  
  <p>what is proper coding convention in this case ?</p>
  
  <p>code snippet :</p>
  
  <pre class="lang-py prettyprint-override"><code>#!/usr/bin/env python3
  
  import discord
  
  jeu = discord.Game("foo")
  client = discord.Client()
  
  
  async def effacer_anciens_message(channel) :
      async for message in channel.history(limit=20) :
          if message.author == client.user :
              await message.delete()
  
  @client.event
  async def on_ready():
      await client.change_presence(activity=jeu)
      for server in client.guilds :
          print (f"{server.name} a pour ID {server.id}")
          if server.name == "my server" :
              for channel in server.channels :
                  if channel.name == "my channel" :
                      ## delete some message
                      await effacer_anciens_message(channel) 
                      ## print/send some message
                      await channel.send("Et maintenant, quelques informations ... ")
                      await afficher_event(channel)
  
      await client.close()
  
  client.run(get_discord_token())
  
  print("disconnected")
  </code></pre>
  
  <p>(this code work, <code>afficher_event()</code> send some message, and <code>get_discord_token()</code> return proper value)</p>