mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-16 06:03:11 +00:00
25 lines
642 B
Python
25 lines
642 B
Python
# This example requires the 'message_content' privileged intent to function.
|
|
|
|
import discord
|
|
|
|
|
|
class MyClient(discord.Client):
|
|
async def on_ready(self):
|
|
print(f'Logged in as {self.user} (ID: {self.user.id})')
|
|
print('------')
|
|
|
|
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'):
|
|
await message.reply('Hello!', mention_author=True)
|
|
|
|
|
|
intents = discord.Intents.default()
|
|
intents.message_content = True
|
|
|
|
client = MyClient(intents=intents)
|
|
client.run('token')
|