mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-05 09:26:10 +00:00
Update examples to match the new rewrite API.
This commit is contained in:
@ -1,22 +1,19 @@
|
||||
import discord
|
||||
|
||||
client = discord.Client()
|
||||
class MyClient(discord.Client):
|
||||
async def on_ready(self):
|
||||
print('Logged in as')
|
||||
print(self.user.name)
|
||||
print(self.user.id)
|
||||
print('------')
|
||||
|
||||
@client.event
|
||||
async def on_message(message):
|
||||
# we do not want the bot to reply to itself
|
||||
if message.author == client.user:
|
||||
return
|
||||
async def on_message(self, message):
|
||||
# we do not want the bot to reply to itself
|
||||
if message.author.id == self.user.id:
|
||||
return
|
||||
|
||||
if message.content.startswith('!hello'):
|
||||
msg = 'Hello {0.author.mention}'.format(message)
|
||||
await client.send_message(message.channel, msg)
|
||||
|
||||
@client.event
|
||||
async def on_ready():
|
||||
print('Logged in as')
|
||||
print(client.user.name)
|
||||
print(client.user.id)
|
||||
print('------')
|
||||
if message.content.startswith('!hello'):
|
||||
await message.channel.send('Hello {0.author.mention}'.format(message))
|
||||
|
||||
client = MyClient()
|
||||
client.run('token')
|
||||
|
Reference in New Issue
Block a user