title: How do I loop a background task in discord.py and why does my code not work?
body: <p>How can I send a message every x time with a discord bot with discord.py?</p>
  <p>Here is my code:</p>
  <pre class="lang-py prettyprint-override"><code>import discord
  from discord.ext import commands
  from discord.ext import tasks
  import os
  
  TOKEN = 'xxxxxxxxxxx'
  
  
  
  bot = commands.Bot(command_prefix='!',help_command=None,activity=discord.Game(name=&quot;!help&quot;))
  
  
  @tasks.loop(seconds=5)
  async def ping(channel):
      
      print(&quot;is the function being called&quot;)
      
      channel = bot.get_channel(877115461014282320)
      
      await channel.send('embed=embed')
  
  bot.run(TOKEN)
  </code></pre>
  <p>Edit: I know I shouldn't leak my key but I edited it after 10 seconds and removed a letter why could someone still access it?</p>