Answer the question
In order to leave comments, you need to log in
Discord.py command ignoring?
Good afternoon. I made myself a bot and wanted to check for user and guild registration in the database. For this I used on_message to get all the messages from the guilds. But here is the problem. The bot now ignores basic commands. It seems to be googled correctly, but there is no answer. Help
The code itself
client = commands.Bot(command_prefix=config.PREFIX)
client.remove_command('help')
@client.event
async def on_message(ctx):
try:
print(ctx)
except AttributeError:
pass
#Test command
@client.command(pass_context=True)
async def test(ctx):
await ctx.send('`Привет`')
Answer the question
In order to leave comments, you need to log in
FAQ/Why does on_message make my commands stop w... :
Replacing the default `on_message` prevents any additional commands from being executed. To fix this, add the line `bot.process_commands(message)` at the end of your `on_message`, like so:
@bot.event
async def on_message(message):
# делаем что-нибудь тут
await bot.process_commands(message)
in addition: the indents are incorrectly placed, you have 2 of them, but there should be 4 (!)
client = commands.Bot(command_prefix=config.PREFIX)
client.remove_command('help')
@client.event
async def on_message(ctx):
try:
print(ctx)
except AttributeError:
pass
#Test command
@client.command()
async def test(ctx):
await ctx.send('`Привет`')
client.command
in without pass_context
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question