简体   繁体   中英

How do I get this Loop to start with a command

import discord
from discord.ext import commands, tasks
from itertools import cycle
import random
#these imports are for the other parts of the code, I only pasted the parts that keep the code below working

client = commands.Bot(command_prefix = ".")

@client.event
async def on_ready():
    change_status.start()
    print("bot is ready. ")

@tasks.loop(hours=24)
async def Test_lol():
    channel = client.get_channel(CHANNELID)
    await channel.send("Test")
    #test two
@client.command()
async def timer_start(ctx):
    await ctx.Test_lol.start

client.run('MY TOKEN')

I know the ctx.Test_lol.start is the issue but I'm not really sure how to get the loop started with a command so I experimented with ctx . If anyone could provide some insight on how to manually start the loop It would be greatly appreciated.

@client.command()
async def timer_start(ctx):
    Test_lol.start()

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