【问题标题】:on_message event disables all the bot commandson_message 事件禁用所有机器人命令
【发布时间】:2021-04-05 00:24:32
【问题描述】:

我有一个 on_message 事件来阻止具有“静音”角色的用户发送消息:

@client.event
async def on_message(ctx):
    muted=ctx.author.guild.get_role(673180122768998411)
    if muted in ctx.author.roles:
        await ctx.message.delete()

但是对于这个事件,机器人不会对所有命令做出反应。他们不工作。 示例命令:

@client.command(passContent = True)
@commands.has_role("????║Участники")
async def rank(ctx):
    return

【问题讨论】:

    标签: python python-3.x discord discord.py


    【解决方案1】:

    你必须使用这个:

    await client.process_commands(ctx)
    

    因此,您的活动将如下所示:

    @client.event
    async def on_message(ctx):
        muted = ctx.author.guild.get_role(673180122768998411)
        if muted in ctx.author.roles:
            await ctx.delete()
    
        await client.process_commands(ctx)
    

    【讨论】:

      猜你喜欢
      • 2021-06-20
      • 1970-01-01
      • 2021-08-09
      • 2018-11-03
      • 2020-10-26
      • 1970-01-01
      • 1970-01-01
      • 2021-06-15
      • 2021-02-02
      相关资源
      最近更新 更多