The name of this post is confusing but please bear with me.
An example scenario for this would be in discord.py If you are unfamiliar with it please read this example below.
from discord.ext import commands
client = commands.Bot(command_prefix='!')
@client.event
async def on_message(msg):
print(msg.content)
client.run('token')
While it's somewhat trivial for some of you, I would like an explanation on how this works. I would like to be able to receive the data from an event fired in my program like such below:
import time
class bot:
class events:
def on_time_change(ctx):
return ctx
def __init__(self):
while True:
dispatch(time.time, self.events.on_time_change)
time.sleep(1)
calls = bot
@calls.events()
def on_time_change(ctx):
print(ctx) # prints your time dispatched from the init script
Please let me know if this doesn't make any sense, it's my first post, I really need help, thanks!
I've tried searching everywhere and nothing works, I must be wording it wrong.