title: How to make a Discord.py ping cmd
body: <p>I tried lots of other peoples solutions and they didn't work.
  So, how do I get a ping command that shows the ping in MS?</p>
  <p>This is my code and I get no errors whatsoever, tough it just doesn't reply to my CMD.</p>
  <pre class="lang-py prettyprint-override"><code>import os
  from keep_alive import keep_alive
  from discord.ext import commands
  import time
  import random
      
  bot = commands.Bot(
      command_prefix=&quot;!&quot;,  # Change to desired prefix
      case_insensitive=True  # Commands aren't case-sensitive
  )
      
  bot.author_id = 777526936753799189 
     
  @bot.event 
  async def on_ready():  
      print(&quot;I'm in&quot;)
      print(bot.user)  
      
  @bot.event
  async def on_member_join(member):
      await member.create_dm()
      await member.dm_channel.send(
          f'Hi {member.name}, welcome to my Discord server!'
      )
      
  @bot.event
  async def on_message(message):
      if '!test' in message.content.lower():
          await message.channel.send('heyo')
      
  @bot.command()
  async def ping(ctx):
      await ctx.channel.send(f&quot;{client.latency}&quot;)
      
  @bot.command()
  async def test(ctx, arg):
      await ctx.send(arg)
     
      
  extensions = [
      'cogs.cog_example'  
  ]
      
  if __name__ == '__main__':
      for extension in extensions:
          bot.load_extension(extension)
      
      keep_alive()  
      token = os.environ.get(&quot;DISCORD_BOT_SECRET&quot;) 
      bot.run(token)
  </code></pre>
  <p>To simplify stuff, here is the command I used to get the ping response.</p>
  <pre class="lang-py prettyprint-override"><code>@bot.command()
  async def ping(ctx):
      await ctx.channel.send(f&quot;{client.latency}&quot;)
  </code></pre>