I'm using discord.ext.commands to make a discord bot. I made a command that constantly keeps unbanning people even if someone is banned. This is the code:
@client.command(name="unban")
async def unban(ctx):
while True:
bans = await ctx.guild.bans()
if(len(bans)>0):
for ban in bans:
ctx.guild.unban(ban)
await asyncio.sleep(5)
But this is a while loop so I want to terminate this function through another command (say, stop_unban). So I want to know how to terminate the unban function through another function (associated with the stop_unban command).