My goal is to "toggle" a loop when a function is called inside of a cog. I want the function to take the argument of a filename. The function will print the line it has read from a txt file. I want this to loop until I call another function that cancels it.
Discord py uses async, I just do not know how to operate a loop within a function.
Example:
class Looptest:
def __init__(self, client):
self.client = client
#This is responsible for playing the loop.
async def play_loop(self, filename):
filename = (path_to_txtfile)
#loop the following code
with open(filename, 'r') as f:
line = f.readlines()
print(line)
async def stop_loop(self):
#stop the loop