I am trying to understand how Client.event works in discord.py. This is the source code for the event method.
def event(self, coro):
setattr(self, coro.__name__, coro)
According to what I understand, a coroutine is passed into the event function and an attribute of the object is created with name same as the name of the coroutine and the value equal to the output of coroutine. What I don't understand is that what is the object we are talking about?
is the source code for discord.py and I am unable to figure out where an object is being created. Please help.
Also, since a coroutine is taken as an argument, does it mean that only function which are preceded by async can be passed?
What I have tried:
I tried looking for a declaration of an object of the class client
in the source code but could not find one.