Learning objectives
After reading this article you will be able to:
- Compare discord.py, Pycord, Nextcord and hikari on features, style and maintenance
- See the same slash command written in each library
- Pick the right library for your scenario, voice bots included
In Python, four libraries show up in nearly every Discord bot tutorial: discord.py, Pycord, Nextcord and hikari. The first three grew from the same codebase and have similar APIs; the fourth was written from scratch with a different philosophy. All of them talk to the same Discord API, so rate limits, intents and the 3-second interaction deadline are identical whichever you pick.
What changes is the path: how you declare a slash command, when it gets registered, what comes built in and what you assemble yourself. Below, each library runs the same /hello command so you can compare the code side by side.
Why are there so many similar libraries?#
In August 2021, discord.py's author announced the end of development. The community forked it to keep going: Pycord, Nextcord and disnake are the best known. In March 2022, discord.py resumed development, and they have coexisted ever since. The older parts (events, prefix commands, cogs) still look alike; the newer part, slash commands, was implemented differently in each.
That causes two practical problems:
- Package conflict. discord.py and Pycord share the same import name (
import discord). Installing both in one environment breaks one of them, and Pycord's guide says to uninstall discord.py before installingpy-cord. Nextcord (import nextcord) and disnake (import disnake) have their own names. - Mixed-up tutorials. A Pycord slash command example won't run on discord.py, and vice versa. Before copying code, check which library it was written for.
hikari is not a fork: it's an independent project with its own API.
Which criteria matter?#
- Maintenance. Before adopting one, check the date of its latest releases on PyPI and its release notes on GitHub: that pace is what keeps fixes coming when Discord changes the API.
- Slash commands and registration. In discord.py, you sync commands explicitly. Pycord, Nextcord and hikari's arc framework sync on their own when they connect. Registration mechanics are covered in how to create slash commands.
- Voice. Discord only accepts end-to-end encrypted calls (the DAVE protocol) in voice channels. A voice bot needs a library version that implements DAVE: check the release notes before pinning the dependency.
- Structure. discord.py, Pycord and Nextcord bundle the client, commands and utilities in one package. hikari is a microframework: the command framework is your call.
- Gateway or HTTP. discord.py, Pycord and Nextcord revolve around the Gateway connection. hikari also has
RESTBot, which receives only interactions over HTTP; the trade-off is explained in Discord HTTP interactions vs the Gateway. - Python version. Each one declares its minimum version on PyPI, and they don't all require the same. Check before choosing.
When should you choose discord.py?#
discord.py is the original library and the most popular in Python: its repository has the most stars and it's the one that appears most in tutorials and existing answers. It ships discord.ext.commands for prefix commands and cogs, discord.ext.tasks for looping tasks, app_commands for slash commands, and hybrid commands that work with a prefix and a slash at the same time. Voice needs the install extra (pip install "discord.py[voice]").
The /hello command (pip install discord.py), with a manual sync command triggered by mentioning the bot (@YourBot sync):
import os
import discord
from discord import app_commands
from discord.ext import commands
bot = commands.Bot(command_prefix=commands.when_mentioned, intents=discord.Intents.default())
@bot.tree.command(description="Says hello to someone")
@app_commands.describe(name="Who gets the hello")
async def hello(interaction: discord.Interaction, name: str) -> None:
await interaction.response.send_message(f"Hello, {name}!")
@bot.command()
@commands.is_owner()
async def sync(ctx: commands.Context) -> None:
# run it when commands change, not on every startup
synced = await bot.tree.sync()
await ctx.send(f"{len(synced)} command(s) synced")
bot.run(os.environ["DISCORD_TOKEN"])The mention works without the privileged Message Content intent, because messages that mention the bot arrive with their text.
Pros: the most material and examples, a stable API, hybrid commands and built-in voice.
Cons: manual syncing is a frequent cause of "my command doesn't show up" among beginners, and the slash command API (CommandTree, separate decorators) is more verbose than the forks'.
When should you choose Pycord?#
Pycord (the py-cord package on PyPI, imported as discord) made slash commands its main path: discord.Bot, the @bot.slash_command decorator and ctx.respond to reply. Commands sync on their own when the bot connects (auto_sync_commands is on by default), and voice needs the py-cord[voice] extra.
The same /hello (pip install py-cord):
import os
import discord
bot = discord.Bot() # syncs commands on its own when it connects
@bot.slash_command(description="Says hello to someone")
async def hello(ctx: discord.ApplicationContext, name: discord.Option(str, "Who gets the hello")) -> None:
await ctx.respond(f"Hello, {name}!")
bot.run(os.environ["DISCORD_TOKEN"])Pros: a short slash command API, where the command and its options live in the function itself, automatic registration, discord.ext.bridge for commands that work with both a prefix and a slash, and discord.ext.pages for pagination.
Cons: the package conflict with discord.py, and discord.py slash command tutorials that don't apply.
When should you choose Nextcord?#
Nextcord is a discord.py fork with its own package name (import nextcord). Slash commands use @bot.slash_command, and each option is described with SlashOption as the parameter's default value. Commands are registered when the bot connects, and voice needs the nextcord[voice] extra.
The same /hello (pip install nextcord):
import os
import nextcord
from nextcord.ext import commands
bot = commands.Bot() # registers commands on its own when it connects
@bot.slash_command(description="Says hello to someone")
async def hello(
interaction: nextcord.Interaction,
name: str = nextcord.SlashOption(description="Who gets the hello"),
) -> None:
await interaction.send(f"Hello, {name}!")
bot.run(os.environ["DISCORD_TOKEN"])Pros: it can live next to discord.py in the same environment, automatic registration, an events and commands API that feels familiar coming from discord.py, and built-in voice.
Cons: a smaller community than discord.py's, with fewer third-party examples.
When should you choose hikari?#
hikari describes itself as a statically typed microframework for the Discord API, with REST and Gateway support. It ships no command framework: the project itself points to lightbulb, tanjun, crescent or arc. That keeps the core lean and leaves the style choice to you. For HTTP interactions, RESTBot spins up a server that receives only interactions. For voice, hikari only defines the interface: playback comes from an external library, usually a Lavalink client.
The same /hello with arc (pip install hikari hikari-arc):
import os
import arc
import hikari
bot = hikari.GatewayBot(os.environ["DISCORD_TOKEN"]) # for HTTP: hikari.RESTBot with arc.RESTClient
client = arc.GatewayClient(bot) # syncs commands at startup
@client.include
@arc.slash_command("hello", "Says hello to someone")
async def hello(ctx: arc.GatewayContext, name: arc.Option[str, arc.StrParams("Who gets the hello")]) -> None:
await ctx.respond(f"Hello, {name}!")
bot.run()Pros: strict typing that your editor and checkers like mypy can use, a modular architecture, a built-in HTTP mode and performance extras (hikari[speedups]).
Cons: more pieces to choose and wire together, fewer tutorials, and voice only through an external library. The command frameworks keep different maintenance paces: check the release history of the one you pick.
How do the four compare, and which should you pick?#
| discord.py | Pycord | Nextcord | hikari | |
|---|---|---|---|---|
| Origin | Original | discord.py fork | discord.py fork | Written from scratch |
| Import | discord |
discord |
nextcord |
hikari |
| Slash commands | app_commands and CommandTree |
@bot.slash_command |
@bot.slash_command |
lightbulb, tanjun, crescent or arc |
| Command registration | Manual (tree.sync) |
Automatic on connect | Automatic on connect | Depends on the framework (arc syncs at startup) |
| Voice | Built in ([voice]) |
Built in ([voice]) |
Built in ([voice]) |
Interface only; playback via an external library |
| HTTP interactions | Gateway-focused | Gateway-focused | Gateway-focused | RESTBot |
| Strength | Material and stability | Short slash API | Own name and auto registration | Typing and modularity |
| Scenario | Recommendation |
|---|---|
| First bot, following tutorials | discord.py |
| Slash commands only, without thinking about sync | Pycord or Nextcord |
| Music or voice bot | discord.py, Pycord or Nextcord on a version that implements DAVE, or any of them with Lavalink |
| Large bot with strict typing and modules | hikari with the command framework you prefer |
| Interactions only, on an HTTP server | hikari with RESTBot |
| Existing bot that works | Keep the library; migrate only for a missing feature |
There is no universal winner. A well-structured bot in any of the four covers most cases, and the language matters more than the library, as shown in the best language for a Discord bot. Once you've chosen, the next step is keeping the process running nonstop: see how to host a Python Discord bot.
How to do this on Square Cloud#
On Square Cloud, the library choice is yours: Discord bot hosting supports discord.py or any Gateway library, with sharding and voice, and FFmpeg ships in the container. The Python runtime installs dependencies at start with pip install -r requirements.txt, so you just list the library you picked in that file.
You deploy by ZIP upload in the dashboard, the CLI, GitHub or the VS Code extension, and the token goes in the application's environment variables, with changes applying on the next restart. The squarecloud.app file is optional: the dashboard generates it at deploy, and writing it at the project root is the alternative. A Lavalink server runs as a separate web application in the same account, from 512 MB.
The bot runs in an isolated, always-on container, with automatic restart (on by default for dashboard deploys) when the process exits with an error. Each bot uses at least 256 MB from the plan's RAM pool, and Hobby costs R$12.49 per month with 1 GB. See Discord bot hosting.
Bot hosting
Keep your bot online 24/7 with automatic restarts
FAQs
Is discord.py still maintained?
Development stopped in August 2021 and the author resumed it in March 2022. To see the current pace, check the date of the latest releases on PyPI and the release notes in the official repository, Rapptz/discord.py.
Can I install discord.py and Pycord together?
No. Both use the same import name, discord, and one overwrites the other. Pycord's guide says to uninstall discord.py before installing py-cord. Nextcord and disnake use their own names and don't conflict.
Which Python library supports Discord voice?
discord.py, Pycord and Nextcord have built-in voice, installed with pip's [voice] extra. Since Discord requires the DAVE protocol in voice channels, check the release notes in the official repository to confirm the version you install implements it. hikari only defines the voice interface; playback comes from an external library, usually a Lavalink client.
Can I migrate from discord.py to Pycord or Nextcord?
Yes, since all three share the same base, and events and prefix commands look alike. Slash commands differ a lot between them, so rewrite that part following the new library's documentation.
More in Bots
See all 39 articles- How much does it cost to host a Discord bot?The cost of hosting a Discord bot depends on RAM, uptime, database and outside services. Learn how to estimate your own bill and where the money goes.
- Running a bot on your phone or PC vs hosting itA bot on your PC or phone (Termux) goes offline when the device shuts down, sleeps or loses its network. Compare the three options and when each one fits.
- How to host a Discord bot 24/7To keep a Discord bot online 24/7, run its process on an always-on machine with automatic restarts. Compare your PC, a VPS with pm2 or systemd, and bot hosting.
- Why your Discord bot keeps going offline (and how to fix it)A Discord bot goes offline when the process dies, the token is invalid, an intent is disabled or memory runs out. Learn to diagnose each cause and fix it.