0

I have been making a discord bot game recently, and want there to be daily events that players can join and compete in. But I want these events to appear automatically, without the client doing anything. I've thought about using the cooldown() function that discord offers and time.sleep(). But how would the bot know where to send the message?

Here's a short part if what I've tried:

import discord
from discord.ext.commands import command, cooldown

@cooldown(1, 86400, '''What type should I use here?''')
async def '''what kind of function?'''():
   await '''What should I use to send'''("@everyone, a new event has appeared! **INFO**...")
plr108
  • 1,201
  • 11
  • 16

1 Answers1

0

For this, you should use tasks. There are examples in the docs.

Kanin
  • 392
  • 2
  • 12
  • [Here's an example running a task at the same time every day](https://stackoverflow.com/a/61180222/6779307) – Patrick Haugh Jul 29 '20 at 19:36
  • But how would the bot know where to send the message? – Rodion Zuban Jul 29 '20 at 19:56
  • You could use [fetch_channel](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.fetch_channel) I strongly suggest you read the docs and get comfortable with them before trying to write a functional bot. – Kanin Jul 29 '20 at 20:05
  • You could also use [get_channel](https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.get_channel). Both have their use case and with the very little amount of info you've provided, I'm not sure which is best for you. – Kanin Jul 29 '20 at 20:07