How make discord.ext.tasks send in channel by id every x minutes in cogs
bot.get_channel
method retrives channel from cache. You can properly do it only after on_ready
event:
class Test(commands.Cog):
def __init__(self, bot):
self.bot = bot
@tasks.loop(minutes=1.0)
async def test1(self):
channel=bot.get_channel(927612404056092702)
channel.send(mensagem)
@commands.Cog.listener()
async def on_ready(self):
if not self.test1.is_running():
self.test1.start()
def setup(bot):
bot.add_cog(Test(bot))