Answer the question
In order to leave comments, you need to log in
Discord.py how to run two loops at once?
Here is the code:
from threading import Thread
import discord
from discord.ext import commands
bot = commands.Bot(command_prefix='!')
@bot.command(pass_context=True)
async def f(ctx):
for i in range(3):
await ctx.send('Test2')
@bot.command(pass_context=True)
async def f_2(ctx):
for i in range(3):
await ctx.send('Test')
th_1, th_2 = Thread(target=f), Thread(target=f_2)
@bot.command(pass_context=True)
async def test1(ctx):
th_1.start(), th_2.start()
th_1.join(), th_2.join()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question