дискорд стоп функция

TopCarl

Участник
Автор темы
108
14
написал небольшого бота в дискорде чтобы флудил чат с активацией на команду, но хотелось бы узнать как останавливать это тоже с помощью команды
1:
@client.command()
async def popka(ctx):
  for i in range(2000000):
    guild = ctx.message.guild
    await ctx.channel.send("flood text")
 

VRush

https://t.me/vrushscript
Проверенный
2,347
1,091
делаешь команду /stop:
stop = True

Python:
@client.command()
async def popka(ctx):
    for i in range(2000000):
        if stop:
            wait ctx.channel.send("flood stoped")
            return
        guild = ctx.message.guild
        await ctx.channel.send("flood text")
 

ChromiusJ

PARΛDIGM ΛSS
Друг
4,909
3,197
Python:
is_flooding = False

@client.command()
async def popka(ctx):
    global is_flooding
    is_flooding = True
    while is_flooding:
        guild = ctx.message.guild
        await ctx.channel.send("flood text")

@client.command()
async def stop(ctx):
    global is_flooding
    is_flooding = False
где нибудь объявляешь переменную флуда да и все