Не работает строка await bot.process_commands discord.py

Рейтинг: 0Ответов: 1Опубликовано: 15.02.2023

Суть заключается в том, что бот должен переписывать сообщение в эмбет и на свой эмбет ставить реакции, соответственно удалять оригинал. Оно работает НО не работают команды. Я уже пробывал await bot.process_commands(ctx) но бесполезно. Вот весь код:

from discord.ext import commands

print("Starts...")

intents = discord.Intents.all()

bot = commands.Bot(command_prefix='g.',intents=intents)

@bot.event
async def on_message(ctx):
    if ctx.author != bot.user:
        channel = bot.get_channel(1073146856223293530)
        if channel.id == ctx.channel.id:
            await ctx.delete()
            embed = discord.Embed(title=f"От: {ctx.author.name}", description=ctx.content, color=0x3498db)
            message = await channel.send(embed=embed)
            await message.add_reaction('👍')
            await message.add_reaction('👎')
            # не работает↓
            await bot.process_commands(ctx)


@bot.command()
async def hello(ctx):
    author = ctx.message.author
    await ctx.send(f'Hello, {author.mention}!')

bot.run("TOKEN")

Если же убрать то что дальше bot.event к bot.command, то команды будут работать.

Ответы

▲ 0Принят

Сколько же пришлось долбиться, и вот спустя времени я исправил ошибку. Всего лишь нужно было вывести await bot.process_commands(ctx) с ифа. Если понятнее то просто нужно убрать 4 лишних пробела, или 1 лишний таб в строке с этим. Полный код:

from discord.ext import commands

print("Starts...")

intents = discord.Intents.all()

bot = commands.Bot(command_prefix='g.',intents=intents)

@bot.event
async def on_message(ctx):
    if ctx.author != bot.user:
        channel = bot.get_channel(1073146856223293530)
        if channel.id == ctx.channel.id:
            await ctx.delete()
            embed = discord.Embed(title=f"От: {ctx.author.name}", description=ctx.content, color=0x3498db)
            message = await channel.send(embed=embed)
            await message.add_reaction('👍')
            await message.add_reaction('👎')
        await bot.process_commands(ctx)


@bot.command(name='hello')
async def hello(ctx):
    author = ctx.message.author
    await ctx.send(f'Hello, {author.mention}!')


bot.run("TOKEN")

И да, поздравьте меня.