Discord.py: on_message reacts to itself

Created on 21 Oct 2019  路  8Comments  路  Source: Rapptz/discord.py

I tried using if not message.author.bot: but it still react to itself.
I searched on google, but i didn't find any useful solution.
I asked this on the official discord server, but nobody knew the answer :c

I will be very happy if someone could give me any useful information.

All 8 comments

Show the code probably?

Show the code probably?

    @commands.Cog.listener()
    async def on_message(self, message):
        if not messgae.author.bot:
            if message.channel.type == discord.ChannelType.private:
                # some stuff here
  1. There's no error there, maybe you have a selfbot or you didn't restart the bot.
    Also, better check it like bot.user.id != message.author.id
    2.The issues page is for library issues, for questions about your code ask in the support guild
  1. There's no error there, maybe you have a selfbot or you didn't restart the bot.
    Also, better check it like bot.user.id != message.author.id
    2.The issues page is for library issues, for questions about your code ask in the support guild

Try this:

    @commands.Cog.listener()
    async def on_message(self, message):
        if not message.author.bot:
            if message.channel.type == discord.ChannelType.private:
                print("asd")

    @commands.command()
    async def test(self,ctx):
        await ctx.author.send("test")

When you type [prefix]test it will send the message and the bot will print asd.
And that is what I don't want.

Same with bot.user.id != message.author.id.

You've spelled message incorrectly as messgae.

When you type [prefix]test it will send the message and the bot will print asd.
And that is what I don't want.

But in that case, the message author would NOT be bot - it would be the person that typed [prefix]test. Can you explain?

Why did you delete the issue template instead of filling it out?

You've spelled message incorrectly as messgae.

When you type [prefix]test it will send the message and the bot will print asd.
And that is what I don't want.

But in that case, the message author would NOT be bot - it would be the person that typed [prefix]test. Can you explain?

Why did you delete the issue template instead of filling it out?

Ok, I wrote it bad, but when I write it correct it will not fix the issue 馃槩

Have you tried this?
```@commands.Cog.listener()
async def on_message(self, message):
if message.author.bot:
return print('Bot, ignoring.')
if message.channel.type == discord.ChannelType.private:
print("Private DM")

Was this page helpful?
0 / 5 - 0 ratings

Related issues

superloach picture superloach  路  3Comments

Yolotroll101 picture Yolotroll101  路  3Comments

AraHaan picture AraHaan  路  3Comments

TunaHobby picture TunaHobby  路  3Comments

adhoc92 picture adhoc92  路  3Comments