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'):
        await client.send_message(message.channel, 'Hello world!')

client.run('paste_token_here')
import asyncio

import discord
from   discord.ext import commands



bot = commands.Bot(command_prefix='!', description='test')

@bot.event
async def on_ready():
    print('Logged in as')
    print(bot.user.name)
    print(bot.user.id)
    print('------')
    
@bot.command()
async def test():
    await bot.say('Hello World!')

bot.run('paste_token_here')

Switch to Bot object instead of Client
Switch to Bot object instead of Client

Better reflects examples in discord.py project

- import discord
  import asyncio
  
- client = discord.Client()
+ import discord
+ from   discord.ext import commands
  
- @client.event
+ 
+ 
+ bot = commands.Bot(command_prefix='!', description='test')
+ 
+ @bot.event
  async def on_ready():
      print('Logged in as')
-     print(client.user.name)
+     print(bot.user.name)
-     print(client.user.id)
+     print(bot.user.id)
      print('------')
+     
+ @bot.command()
+ async def test():
+     await bot.say('Hello World!')
  
+ bot.run('paste_token_here')
- @client.event
- async def on_message(message):
-     if message.content.startswith('!test'):
-         await client.send_message(message.channel, 'Hello world!')
  
- client.run('paste_token_here')
Switch to Bot object instead of Client
## 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'):
        await client.send_message(message.channel, 'Hello world!')

client.run('paste_token_here')
## Instruction:
Switch to Bot object instead of Client
## Code After:
import asyncio

import discord
from   discord.ext import commands



bot = commands.Bot(command_prefix='!', description='test')

@bot.event
async def on_ready():
    print('Logged in as')
    print(bot.user.name)
    print(bot.user.id)
    print('------')
    
@bot.command()
async def test():
    await bot.say('Hello World!')

bot.run('paste_token_here')
