1import discord
2
3client = discord.Client()
4
5@client.event
6async def on_ready():
7 print('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')
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')
1import discord
2
3class MyClient(discord.Client):
4 async def on_ready(self):
5 print('Logged on as', self.user)
6
7 async def on_message(self, message):
8 # don't respond to ourselves
9 if message.author == self.user:
10 return
11
12 if message.content == 'ping':
13 await message.channel.send('pong')
14
15client = MyClient()
16client.run('token')
17