#Automation not working

1 messages · Page 1 of 1 (latest)

clever sluice
#
    
@tasks.loop(time=time(15, 7, tzinfo=timezone.utc))
    async def schedule_daily_report(self):

        print("sending data")

        log_channel_id = channelidthatiwontshow
        channel = self.bot.get_channel(log_channel_id)
        if channel is not None:
            data = {
                'suspensions': self.get_suspensions(),
                'promotions': self.get_promotions(),
                'infractions': self.get_infractions()
            }
            data_str = str(data)
            encoded_data = base64.b64encode(data_str.encode()).decode()
            await channel.send(f"Encrypted data:\n\n{encoded_data}\n")
        else:
            print("Channel not found.")

I am sooo conufed...

cyan hinge
#

Ach, jetzt kommste hier her

night laurel
#

what is not working?
The loop does not run?
The channel is not found
etc?

clever sluice
clever sluice
clever sluice
warm ridge
#

that is not a description of the problem.

#

what doesnt work.

night laurel
#

Can you confirm that the bot is online?

warm ridge
#

which line. does it print the first print. etc

#

and are you starting the task at all

night laurel
#

^ You should be starting the task somewhere with schedule_daily_report.start()

clever sluice
#

I simplified to this:

    @tasks.loop(time=time(0, 0, tzinfo=timezone.utc))
    async def time_task(self):

        print("test")
clever sluice
#

And yes, the loop just won't work.

#

Yes I start the task

warm ridge
#

again, does it ever print?

night laurel
#

Can you show how you are starting the task? And if its in a cog how you load the cog

clever sluice
clever sluice
warm ridge
#

i mean, it wont run until the time, yknow

night laurel
#

You probably do not want to start it in on_ready can you try starting it in the __init__ of the cog?

#

on_ready can run multiple times and that would start your task multiple times I think. Not the issue here but could be in the future

clever sluice
warm ridge
#

change the time.

clever sluice
#

I did to 20:04

#

So it Should do now

#

IT DID

#

FINNALY WHAT

#

WHY

#

ARGS