Skip to main content

Build powerful Discord bots with Python

Pycord is a modern, feature-rich Python library that makes it easy to create Discord bots with slash commands, UI components, voice support, and more.

Quick start

Get your first bot running in minutes

1

Install Pycord

Install the library using pip. For full voice support, include the [voice] extra.
# Basic installation
python3 -m pip install -U py-cord

# With voice support
python3 -m pip install -U "py-cord[voice]"
2

Create a Discord application

Go to the Discord Developer Portal and create a new application. Navigate to the Bot section and create a bot user. Copy your bot token for the next step.
Never share your bot token publicly. Treat it like a password.
3

Write your first bot

Create a new Python file and add this code:
import discord

bot = discord.Bot()

@bot.slash_command()
async def hello(ctx, name: str = None):
    name = name or ctx.author.name
    await ctx.respond(f"Hello {name}!")

bot.run("your-token-here")
4

Invite and test your bot

In the Developer Portal, go to OAuth2 → URL Generator. Select the bot and applications.commands scopes, then copy the generated URL to invite your bot to your server. Run your Python script and use the /hello command!

Key features

Everything you need to build amazing Discord bots

Slash commands

Create modern slash commands with autocomplete, options, and subcommands

UI components

Build interactive interfaces with buttons, select menus, and modals

Voice support

Connect to voice channels and play audio with built-in voice clients

Cogs & extensions

Organize your bot code with modular cogs and reusable extensions

Event system

React to Discord events like messages, reactions, and member updates

Prefix commands

Support traditional text-based commands with powerful parsing

Community & support

Get help and connect with other developers

Discord server

Join our active community Discord server for help and discussions

GitHub

Report bugs, request features, and contribute to the project

Examples

Browse real-world code examples for common bot features

Guide

Read our comprehensive guide for building Discord bots

Ready to build your Discord bot?

Start with our quickstart guide and have your first bot running in minutes.

Get Started Now

Build docs developers (and LLMs) love