Q
Q
Quaasaar2020-05-16 10:43:29
Python
Quaasaar, 2020-05-16 10:43:29

Discord.py how to stop single and multiple loops?

I need to make it so that there is a command that stops a certain cycle or all cycles at once. I wrote the code, but it doesn't work...

import discord
from discord.ext import commands

client = commands.Bot(command_prefix='!')


global stop1


@client.command(pass_context=True)
async def stopp(ctx):
    #global stop1
    stop1 = True


@client.command(pass_context=True)
async def test1(ctx):
    stop1 = False
    while True:
        await ctx.send('Test')
        if stop1 == True:
            break

client.run ("TOKEN")
I tried to put global in place of the comment - it doesn't work. There is no error at all, but the code is not working, what's the problem?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question