title: Add cooldown / timer to on_message [Discord.py]
body: <p>I got into making a Discord bot in Python very recently (testing the grounds of Python with it) and created a functioning one with several commands myself. To widen its uses, I have added a level/XP system, which is working so far. </p>
  
  <pre><code>[...]
  @bot.event
  async def on_message(message):
          user_add_xp(message.author.id, 2)
          await bot.process_commands(message)
  
  # commands go here
  
  def user_add_xp(user_id, xp):
      if os.path.isfile('users.json'):
              try:
                      with open('users.json', 'r') as fp:
                              users = json.load(fp)
                      users[user_id]['xp'] += xp
                      with open('users.json', 'w') as fp:
                              json.dump(users, fp, sort_keys=True, indent=4)
              except KeyError:
                      with open('users.json', 'r') as fp:
                              users = json.load(fp)
                      users[user_id] = {}
                      users[user_id]['xp'] = xp
                      with open('users.json', 'w') as fp:
                              json.dump(users, fp, sort_keys=True, indent=4)
      else:
          users = {user_id: {}}
          users[user_id]['xp'] = xp
          with open('users.json', 'w') as fp:
                  json.dump(users, fp, sort_keys=True, indent=4)
  [...]
  </code></pre>
  
  <p>But to prevent users from just flooding/spamming some channels and rocketing to the top, I want to add a cooldown/timer on the awarding of XP. I have tried to add <code>@commands.cooldown(1, 120, commands.BucketType.server)</code> to both <code>@bot.event</code> and <code>user_add_xp</code>, but both do not get me the desired result.
  I have no other idea how to add this cooldown/timer.</p>
  
  <p>In the end, I want the bot to only grant XP once every two minutes.</p>