import discord
import asyncio

client = discord.Client()

@client.event
async def on_ready():
    print('Logged in as')
    print(client.user.name)
    print(client.user.id)
    print('------')

@client.event
async def on_message(message):
    if message.content.startswith('!test'):
        counter = 0
        tmp = await client.send_message(message.channel, 'Calculating messages...')
        async for log in client.logs_from(message.channel, limit=100):
            if log.author == message.author:
                counter += 1

        await client.edit_message(tmp, 'You have {} messages.'.format(counter))
    elif message.content.startswith('!sleep'):
        await asyncio.sleep(5)
        await client.send_message(message.channel, 'Done sleeping')

client.run('token')
import discord
import asyncio
import os

#Set up Client State
CLIENT_TOKEN=os.environ['TOKEN']

client = discord.Client()

@client.event
async def on_ready():
    print('Logged in as')
    print(client.user.name)
    print(client.user.id)
    print('------')

@client.event
async def on_message(message):
    if message.content.startswith('!test'):
        counter = 0
        tmp = await client.send_message(message.channel, 'Calculating messages...')
        async for log in client.logs_from(message.channel, limit=100):
            if log.author == message.author:
                counter += 1

        await client.edit_message(tmp, 'You have {} messages.'.format(counter))
    elif message.content.startswith('!sleep'):
        await asyncio.sleep(5)
        await client.send_message(message.channel, 'Done sleeping')

client.run(CLIENT_TOKEN)
Use env value for client token
Use env value for client token

  import discord
  import asyncio
+ import os
+ 
+ #Set up Client State
+ CLIENT_TOKEN=os.environ['TOKEN']
  
  client = discord.Client()
  
  @client.event
  async def on_ready():
      print('Logged in as')
      print(client.user.name)
      print(client.user.id)
      print('------')
  
  @client.event
  async def on_message(message):
      if message.content.startswith('!test'):
          counter = 0
          tmp = await client.send_message(message.channel, 'Calculating messages...')
          async for log in client.logs_from(message.channel, limit=100):
              if log.author == message.author:
                  counter += 1
  
          await client.edit_message(tmp, 'You have {} messages.'.format(counter))
      elif message.content.startswith('!sleep'):
          await asyncio.sleep(5)
          await client.send_message(message.channel, 'Done sleeping')
  
- client.run('token')
+ client.run(CLIENT_TOKEN)
Use env value for client token
## Code Before:
import discord
import asyncio

client = discord.Client()

@client.event
async def on_ready():
    print('Logged in as')
    print(client.user.name)
    print(client.user.id)
    print('------')

@client.event
async def on_message(message):
    if message.content.startswith('!test'):
        counter = 0
        tmp = await client.send_message(message.channel, 'Calculating messages...')
        async for log in client.logs_from(message.channel, limit=100):
            if log.author == message.author:
                counter += 1

        await client.edit_message(tmp, 'You have {} messages.'.format(counter))
    elif message.content.startswith('!sleep'):
        await asyncio.sleep(5)
        await client.send_message(message.channel, 'Done sleeping')

client.run('token')
## Instruction:
Use env value for client token
## Code After:
import discord
import asyncio
import os

#Set up Client State
CLIENT_TOKEN=os.environ['TOKEN']

client = discord.Client()

@client.event
async def on_ready():
    print('Logged in as')
    print(client.user.name)
    print(client.user.id)
    print('------')

@client.event
async def on_message(message):
    if message.content.startswith('!test'):
        counter = 0
        tmp = await client.send_message(message.channel, 'Calculating messages...')
        async for log in client.logs_from(message.channel, limit=100):
            if log.author == message.author:
                counter += 1

        await client.edit_message(tmp, 'You have {} messages.'.format(counter))
    elif message.content.startswith('!sleep'):
        await asyncio.sleep(5)
        await client.send_message(message.channel, 'Done sleeping')

client.run(CLIENT_TOKEN)