Add some examples

This commit is contained in:
Rapptz 2015-08-21 18:24:04 -04:00
parent 3e0f09d32c
commit a90e804192
3 changed files with 36 additions and 0 deletions

View File

@ -31,6 +31,8 @@ def on_ready():
client.run()
```
You can find examples in the examples directory.
## Requirements
- Python 2.7+ or Python 3.3+.

16
examples/echo.py Normal file
View File

@ -0,0 +1,16 @@
import discord
client = discord.Client()
client.login('email', 'password')
@client.event
def on_ready():
print('Connected!')
print('Username: ' + client.user.name)
print('ID: ' + client.user.id)
@client.event
def on_message(message):
client.send_message(message.channel, message.content)
client.run()

18
examples/reply.py Normal file
View File

@ -0,0 +1,18 @@
import discord
client = discord.Client()
client.login('email', 'password')
@client.event
def on_message(message):
if message.content.startswith('!hello'):
client.send_message(message.channel, 'Hello was received!')
@client.event
def on_ready():
print('Logged in as')
print(client.user.name)
print(client.user.id)
print('------')
client.run()