'Discord.py: Commands don't work but events work, and no errors [duplicate]

I've made a discord bot, but when I run it, events work fine, all the cogs load in correctly. But the commands wouldn't work, when I use a command, it wouldn't show the output.

I used discord.py on version 2.0.0

Here is the code:

import config
import discord
from discord.ext import commands
import random
import json
import os

client = commands.Bot(command_prefix=config.PREFIX)
client.remove_command('help')

@client.event
async def on_ready():
    print('ONLINE')

@client.command()
async def ping(ctx):
    #This is not a actual command I  have but it wouldn't work anyway
    print("Pong")

client.run(config.TOKEN)


Solution 1:[1]

As of Discord.py 2.0, you have to have message intents for normal commands to work properly.

In this example, there are selected default intents which include message_content intent.

import config

from discord import Intents
from discord.ext import commands

client = commands.Bot(command_prefix=config.PREFIX, intents=Intents.default(), help_command=None)

@client.event
async def on_ready():
    print('ONLINE')

@client.command()
async def ping(ctx):
    #This is not a actual command I  have but it wouldn't work anyway
    print("Pong")

client.run(config.TOKEN)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Emil Sležis