samedi 24 avril 2021

randomize time for looping task in discord

I have this code:

import discord
from discord.ext import tasks    
client = discord.Client()
@tasks.loop(minutes=1)
    async def test():
        channel = client.get_channel(MY_CHANNEL)
        await channel.send("hello")

    @client.event
    async def on_ready():
        test.start()

Which basically sends every minute a hello message in my channel. But is it also possible to randomize the time between the message sent. Like for one loop it is 3 and in the other 5...




Aucun commentaire:

Enregistrer un commentaire