title: How to add a function to discord.py event loop?
body: <p>I am using Python with <code>discord.py</code>. Documentation <strong><a href="http://discordpy.readthedocs.io/en/latest/api.html" rel="noreferrer">here</a></strong></p>
  
  <p>I've got a bot that is running on a Discord server that links the server with a subreddit. Users have various commands that do things like getting the top submissions, getting the latest submissions, and so on. </p>
  
  <p>I want to add some features to the bot, with one of them being a keyword notifier. The bot should search the subreddit for keywords in the title, and then notify users if they are on the list for that keyword. I know how to do this, I've done it plenty of times, but I don't know how to do it with a Discord bot. I have no experience with asynchio or any kind of asynchronous programming. </p>
  
  <p>The way I've tried to do it works, but it is very janky and definitely not good. At the top of the <code>on message()</code> function, I just add a call to the <code>search_submissions()</code> function, so that whenever someone puts sends a new message on the server, the bot will scan the Reddit submissions. The server is busy enough that this would work relatively okay, but I really want to do it the "proper" way. </p>
  
  <p>I don't know how to call the <code>search_submissions()</code> function without putting it inside of <code>on_message()</code>. </p>
  
  <hr>
  
  <p>Edit for extra code:</p>
  
  <pre><code>import discord
  
  TOKEN = "redacted"
  client = discord.Client()
  
  @client.event
  async def reddit_search():
      print("Searching")
  
  @client.event
  async def on_message(message):
      if message.content.startswith("reddit!hot"):
          # Get hot
      # Do other things.
  
  @client.event
  async def on_ready():
      print("Connected to Discord as {}.".format(client.user.name))
  
  client.run(TOKEN)
  </code></pre>