1import discord
2
3client = discord.Client()
4
5@client.event
6async def on_ready():
7 print('We have logged in as {0.user}'.format(client))
8
9@client.event
10async def on_message(message):
11 if message.author == client.user:
12 return
13
14 if message.content.startswith('$hello'):
15 await message.channel.send('Hello!')
16
17client.run('your token here')
1@bot.event
2async def on_message(message):
3 if isinstance(message.channel, discord.channel.DMChannel) and message.author != bot.user:
4 await message.channel.send('This is a DM')