ShadowNotFake
ShadowNotFake

Reputation: 114

on_message event disables all the bot commands

I have an on_message event to prevent users with "Muted" role from sending messages:

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

But with this event bot doesn't react to all the commands. They are not working. Example command:

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

Upvotes: 1

Views: 79

Answers (1)

Sujit
Sujit

Reputation: 1792

You have to use this:

await client.process_commands(ctx)

So, your event will look like this:

@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)

Upvotes: 2

Related Questions