Discord.py on_message 事件未处理任何命令 - Modmail 事件

Discord.py on_message event isn't processing any commands - Modmail Event

我正在创建一个 mod-mail 功能,成员可以向 bot 发送消息,它会回复指令。但是,除了机器人命令外,该事件工作正常。这是我的代码。奇怪的是没有检测到错误。

sent_users = []
modmail_channel = client.get_channel(910023874727542794)

@client.event
async def on_message(message):
    if message.guild:
        return
    if message.author == client.user:
        return
    if message.author.id in sent_users:
        return

    embed = discord.Embed(color = color)
    embed.set_author(name=f"Misaland Modmail System", icon_url=f'{message.author.avatar_url}')
    embed.add_field(name='Report a Member: ', value=f"React with <:Wojak1:917122152078147615> if you would like to report a member.")
    embed.add_field(name='Report a Staff Member:', value=f"React with <:grim1:925758467099222066> if you would like to report a staff.")
    embed.add_field(name='Warn Appeal:', value=f"React with <:Lovecat:919055184125100102> if you would like to appeal a warning.")
    embed.add_field(name='Question:', value=f"React with <:gasm:917112456776679575> if you have a question about the server")
    embed.add_field(name='Leave a Review', value=f"React with <:surebuddy1:917122193287163924> to leave a review about the server")
    embed.add_field(name='Server Invite', value=f'React with <:smirk:910565317363773511> to get the server invite.')
    embed.set_footer(text='Any questions asked that isnt related to the list, you will be severely abused')
    msg = await message.author.send(embed=embed)

    await msg.add_reaction("<:Wojak1:917122152078147615>")
    await msg.add_reaction("<:grim1:925758467099222066>")
    await msg.add_reaction("<:Lovecat:919055184125100102>")
    await msg.add_reaction("<:gasm:917112456776679575>")
    await msg.add_reaction("<:surebuddy1:917122193287163924>")
    await msg.add_reaction("<:smirk:910565317363773511>")

    sent_users.append(message.author.id)

    try:
        def check(reaction, user):
            return user == message.author and str(reaction.emoji) in ['<:Wojak1:917122152078147615>', '<:grim1:925758467099222066>','<:Lovecat:919055184125100102>','<:gasm:917112456776679575>','<:surebuddy1:917122193287163924>','<:smirk:910565317363773511>']

        reaction, user = await client.wait_for("reaction_add", timeout=60, check=check)
        

        if str(reaction.emoji) == "<:Wojak1:917122152078147615>":
            embed = discord.Embed(color=color)
            embed.set_author(name=f"Misaland Member Report", icon_url=f'{message.author.avatar_url}')
            embed.add_field(name="How to Report:", value="Send the ID of the person you are reporting and attach a screenshot breaking the rules")
            embed.set_footer(text="Misaland | Member Report")
            await message.author.send(embed = embed)

            message = await client.wait_for("message", timeout=60, check=lambda m: m.channel == message.channel and m.author == message.author)
            embed = discord.Embed(title=f"{message.content}", color=color)
            await modmail_channel.send(embed=embed)
        
            
    except asyncio.TimeoutError:
        await message.delete()

试试放

await bot.process_commands(message)

在您的代码末尾

async def on_message(message):

如果您在 on_message 之外使用命令,它将被覆盖