Issue
@bot.command()
async def start(ctx):
channel = bot.get_channel(#*****)
while True:
if x >= 5:
await channel.Send("Hi")
time.Sleep(1)
@bot.command()
async def stop(ctx):
#Something to stop the while True loop in the 'start' function
I would like to know if there is a way to stop the while loop in the 'start' function by writting something in the 'stop' function.
Solution
You can try something like this:
run_loop = True
@bot.command()
async def start(ctx):
global run_loop
channel = bot.get_channel(#*****)
while run_loop:
if x >= 5:
await channel.Send("Hi")
time.Sleep(1)
@bot.command()
async def stop(ctx):
global run_loop
run_loop = False
Answered By - PApostol
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.