mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-07-13 21:35:30 +00:00
Add some examples
This commit is contained in:
parent
3e0f09d32c
commit
a90e804192
@ -31,6 +31,8 @@ def on_ready():
|
|||||||
client.run()
|
client.run()
|
||||||
```
|
```
|
||||||
|
|
||||||
|
You can find examples in the examples directory.
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
- Python 2.7+ or Python 3.3+.
|
- Python 2.7+ or Python 3.3+.
|
||||||
|
16
examples/echo.py
Normal file
16
examples/echo.py
Normal 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
18
examples/reply.py
Normal 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()
|
Loading…
x
Reference in New Issue
Block a user