Commands don’t run in discord.py 2.0 – no errors, but run in discord.py 1.7.3

Use Intents with discord.py 2.0

  1. Enable Intents

  1. Add your intents to the bot

Let’s add the message_content Intent now.

import discord
from discord.ext import commands

intents = discord.Intents.default()
intents.message_content = True

bot = commands.Bot(command_prefix='$', intents=intents, help_command=None)

  1. Put it together

The code should look like this now.

import discord
from discord.ext import commands

with open('token.txt', 'r') as f: TOKEN = f.read()

# Intents declaration
intents = discord.Intents.default()
intents.message_content = True

bot = commands.Bot(command_prefix='$', intents=intents, help_command=None)

@bot.event
async def on_ready():
    print('bot is ready')

# Make sure you have set the name parameter here
@bot.command(name="test1$", aliases=["test1"])
async def test1(ctx):
    print('test command')

bot.run(TOKEN)

Leave a Comment