-2

This @client.event excludes other commands!!! Pls help me! async def on_message(message): if client.user.mention in message.content.split(): await message.channel.send('xyz') This is my code: (Without the @client.event it works corectly, but when I add other @client.event, rest of the code doesnt works, only client.event works. Guys help!!!


@client.event
async def on_ready():
    print('xyz ~ {0.user}'.format(client))
    await client.change_presence(activity=discord.Game(name="Piwo?"))



  

@client.command()
@has_permissions(ban_members=True)
async def ban(ctx, member : discord.Member, reason="Za darmo lamusie"):
    await member.ban(reason=reason)
    await ctx.channel.send(f"***xyz***")


@client.command()
@has_permissions(kick_members=True)
async def kick(ctx, member : discord.Member, reason="Za darmo lamusie"):
    await member.kick(reason=reason)
    await ctx.channel.send(f"***{member.mention} xyz ***")




@client.command()
async def jaka_gierka(ctx):
    gierki = [xyz]
    await ctx.channel.send(random.choice(gierki))


@client.command()
async def graj(ctx, game):
    await client.change_presence(activity=discord.Game(name=game))

@client.command()
async def streamuj(ctx, game):
    await client.change_presence(activity=discord.Streaming(name=game, url="xyz"))



@client.command()
async def sluchaj(ctx, music):
    await client.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name=music))


@client.command()
async def ogladaj(ctx, film):
    await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name=film))


@client.event
async def on_message(message):
  if client.user.mention in message.content.split():
      await message.channel.send('xyz')



client.run("token")```

1 Answers1

0

You need to process commands in on_message.

Without doing this, none of the commands will execute. The default behavior was to have an on_message that only processed commands. However, you made a custom event handler, so this must be done manually. You can change your on_message to this:

On an unrelated note, checking for the <@1234> mention sequence in the message is a bad idea. Instead, you can use mentions.

@client.event
async def on_message(message):
    if client.user in message.mentions:  # checks if the bot was in the list of people mentioned
        await message.channel.send('xyz')
    await client.process_commands(message)
Eric Jin
  • 3,836
  • 4
  • 19
  • 45