App 8: Build a Discord Bot / Build a Discord bot
Lesson 4 of 10
Your bot comes online
A Client connects to Discord. on_ready runs once the bot is logged in.
Key points
- Intents say what events your bot receives
- on_ready confirms it worked
- client.run(token) starts it
import os, discord
intents = discord.Intents.default()
client = discord.Client(intents=intents)
@client.event
async def on_ready():
print(f"Logged in as {client.user}")
client.run(os.environ["DISCORD_TOKEN"])Your turn
Run the bot and check it shows as online in your server.
Quiz · +10 XP
When does on_ready run?
Log in to save progress and earn XP.