I’ve the following script that’s creating a class MyClient
which is subclassing from discord.Client
class MyClient(discord.Client):
def __init__(self, intents):
super().__init__(intents=intents)
async def on_message(self, message):
if message.author == self.user:
return
In order to prevent the bot from processing messages that it sends, I’ve seen people add if message.author==client.user
in the on_message
event.
However, in my case, the bot ends up processing messages sent both by me and the bot itself. While debugging, I found out that this was happening because self.user
is null.
I was expecting self.user
to be a reference to client.user
since the original client Discord.Client
is now the super class of MyClient
.
How can I correctly grab the client’s user like with client.user
?