title: Can I run a message listener alongside an asynchronous looped task?
body: <p>I'm using discord.py to create a bot that looks for user updates on Anilist periodically. This task is run using discord.Client.loop.create_task(task), and it works as expected. However, when I try to use a message listener alongside this task, the bot does not respond. I've tested this code snippet before and it works, but alongside the task it does not work.</p>
  <p>I've looked at the discord.py documentation and the documentation for create_task on asyncio.AbstractEventLoop, but there is no information about running a message listener concurrently with an AbstractEventLoop.</p>
  <pre class="lang-py prettyprint-override"><code>client = discord.Client()
  
  #message listener
  @client.event
  async def on_message(message):
      if message == &quot;.help&quot;:
          message.channel.send(&quot;test&quot;)
  
  #background task
  @client.event
  @client.event
  async def my_background_task():
      await client.wait_until_ready()
      channel = client.get_channel(458644594905710595)
      while not client.is_closed():
          curr_time = int(time.time()-2)
          variables_pat = {
              'userId': 121769,
              'createdAt_greater': curr_time
          }
  
          variables_hani = {
              'userId': 320308,
              'createdAt_greater': curr_time
  
          }
  
          variables_phil = {
              'userId': 163795,
              'createdAt_greater': curr_time
          }
  
          variables_alan = {
              'userId': 121839,
              'createdAt_greater': curr_time
          }
  
          variables_ben = {
              'userId': 122953,
              'createdAt_greater': curr_time
          }
  
          variables_zen = {
              'userId': 382311,
              'createdAt_greater': curr_time
          }
  
          variables_me = {
              'userId': 323865,
              'createdAt_greater': curr_time
          }
  
          variables_min = {
              'userId': 169966,
              'createdAt_greater': curr_time
          }
          arr_vars = [variables_alan, variables_ben, variables_hani, variables_pat, variables_phil, variables_zen,
                      variables_me, variables_min]
          for variables in arr_vars:
              response = requests.post(url, json={'query': query, 'variables': variables})
              my_json = json.loads(response.content)
              if my_json[&quot;data&quot;] is not None and my_json[&quot;data&quot;][&quot;Activity&quot;] is not None:
                  activity = my_json[&quot;data&quot;][&quot;Activity&quot;]
                  print(activity)
                  if activity[&quot;progress&quot;] is not None:
                      result_string = activity[&quot;user&quot;][&quot;name&quot;] + &quot; &quot; + activity[&quot;status&quot;] + &quot; &quot; + activity[&quot;progress&quot;] + &quot; of &quot; + activity[&quot;media&quot;][&quot;title&quot;][&quot;romaji&quot;]
                      result_embed = discord.Embed(
                          title=&quot;New Anilist Post&quot;,
                          color=discord.Color(0x039AFF),
                          description=result_string
                      )
                      await channel.send(embed=result_embed)
                  else:
                      result_string = activity[&quot;user&quot;][&quot;name&quot;] + &quot; &quot; + activity[&quot;status&quot;] + &quot; &quot; + activity[&quot;media&quot;][&quot;title&quot;][&quot;romaji&quot;]
                      result_embed = discord.Embed(
                          title=&quot;New Anilist Post&quot;,
                          color=discord.Color(0x039AFF),
                          description=result_string
                      )
                      await channel.send(embed=result_embed)
  
  client.loop.create_task(my_background_task())
  client.run(os.getenv(&quot;DISCORD_TOKEN&quot;))
  </code></pre>