title: How to dm all in discord server
body: <p>This is my code for discord self bot. It will first check if the token is valid and if it is valid it will then log in to that token. Nothing happens after it login(it is supposed to print status: online ) as per the client.event() on_ready. I think my small command is also broken please help.</p>
  <pre><code>def Bot_run():
      Token = input(&quot;DISCORD TOKEN : &quot;)
      request_url = &quot;https://canary.discordapp.com/api/v6/users/@me&quot;
  
      req = requests.get(request_url, headers={'authorization': Token})
      if req.status_code == 401:
          print(f&quot;The token : {Token} is invalid&quot;)
          inv = input(&quot;press enter to close&quot;)
          exit()
      if req.status_code == 200:
          print(f&quot;The token : {Token} is valid&quot;)
          
      client.run((Token),bot=False)
  
  @client.event
  async def on_ready():
      print('status : online')
  
  @client.command()
  async def dmall(ctx,*,message):
      for member in ctx.guild.members:
          await ctx.message.delete()
          try:
              await member.send(message)
              print(f'Sent dm to: {member.name}')
          except:
              print(f'failed to send message to {member.name}')
  </code></pre>