Python on_消息事件禁用所有bot命令
我有一个on_消息事件,用于阻止具有“静音”角色的用户发送消息:Python on_消息事件禁用所有bot命令,python,python-3.x,discord,discord.py,Python,Python 3.x,Discord,Discord.py,我有一个on_消息事件,用于阻止具有“静音”角色的用户发送消息: @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.comm
@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("You have to use this:
await client.process_commands(ctx)
@client.command(passContent=True)
@commands.has_role(“您必须使用以下命令:
wait client.process_命令(ctx)
因此,您的活动将如下所示:
@client.event
异步def on_消息(ctx):
mute=ctx.author.guild.get_角色(673180127268998411)
如果在ctx.author.roles中禁用:
等待ctx.delete()
等待客户端处理命令(ctx)