#"self" is not defined

1 messages · Page 1 of 1 (latest)

bold bobcat
#

Could I pass self when dealing with tasks in extensations?


@Task.create(IntervalTrigger(seconds=5))
        now = datetime.datetime.now(self.timezoneInfo)
        
        if x.now().hour == 8 and x.now().minute == 0 and self.alreadyposted == False:
            self.alreadyposted = True 

            question = self.random_qotd_question()

            if question == None:
                user = self.client.get_user(247036279420747776)
                await user.send("You ran out of questions in the database.")
                return

            guild = await self.client.fetch_guild(864557936068395018)

            channel = await guild.fetch_channel(1095806073639805019)

            embed = Embed("Question of the Day")
            embed.add_field("Question", question)
            embed.color = Color.from_rgb(201, 234, 252)

            await channel.send("<@&890470398192402493>", embeds=embed)

        elif x.now().hour != 8 and x.now().minute != 0 and self.alreadyposted == True:
            self.alreadyposted = False

proven loomBOT
#

Hey! Once your issue is solved, press the button below to close this thread!

silent geyser
#

.. is the function declaration missing?

#

Also, please specify your problem

proven loomBOT
#

You are trying to ask a question about your attempt at solving a problem instead of the problem you are trying to solve. https://xyproblem.info

bold bobcat
#

how would i get self

silent geyser
#

You can't pass class attributes into decorators

#

You'd have to define a constant outside of the class and write to it, then use that. However, the value of that needs to be known when compiling, otherwise it's unbound when runtime

bold bobcat
#

oh im missing async def name() in it

#

my bad