【发布时间】:2021-11-07 15:08:52
【问题描述】:
我目前正在尝试制作一个启动 selenium 线程的不和谐机器人。它可以工作,但唯一的问题是,如果 selenium 花费太长时间,我将无法使用其他命令。它最终会响应下一个命令,但只有在 selenium 完成后才会响应。
这就是我所拥有的:
import threading
import discord
import time
from selenium import webdriver
from discord.ext import tasks, commands
client = commands.Bot(command_prefix='!')
def start(url):
driver = webdriver.Firefox()
driver.get(url)
time.sleep(10)
driver.close()
@client.command()
async def rq(ctx):
#if link == None:
#await ctx.send("Please send a link!")
await ctx.send("Started!")
threading(target=start("https://google.com/")).start()
@client.command()
async def sc(ctx):
await ctx.send("some command")
if __name__ == "__main__":
client.run(token)
任何解决方案都会有所帮助!
【问题讨论】:
-
请提供足够的代码,以便其他人更好地理解或重现问题。
标签: python python-3.x selenium discord discord.py