简体   繁体   中英

Discord.py run function in class at specific time

How do I run the DiscordClient().announceChallenge() every day at 14:00 with the bot/script running 24/7?

imports

class DiscordClient(discord.Client):
    def __init__(self):
        super().__init__()

    async def on_ready(self):
        print('Logged on as {0}!'.format(self.user))
    
    async def announceChallenge(self):)
        print("Announced the daily challenge")

client = DiscordClient()
client.run(token)```

Read the docs about the sched module .

Here is a simple tutorial.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM