我在这里拥有的所有代码都在另一个循环中,但是当我运行代码时,一旦到达bot.run行,它就会停止。一旦它到达bot.run行,它就会发送消息。我不能将该行放在代码的末尾,因为我所谈论的循环是一个永无止境的循环。我需要在循环内发送消息。我该怎么办?
@bot.event
async def on_ready():
bb = 1
g = 0
while g <= len(NewProdNames) - 1:
if g == 2:
bb = 2 - 5
print('{0.user} is online!'.format(bot))
embed = discord.Embed(title="Archive Restock", description=NewProdNames[g],
color=discord.Color.from_rgb(3, 236, 252))
embed.set_thumbnail(url=br.find_element_by_xpath('//*[@id="search-results-container"]/div[' + str(productNumbers[g] + bb) + ']/div/div[1]/a[1]/img').get_attribute('data-image-first'))
embed.set_footer(text="Archive Restock Monitor | VirtualKicks",
icon_url='https://cdn.shopify.com/s/files/1/0269/8146/6177/files/Mooi_large.jpg')
await bot.get_channel(Channel id).send(embed=embed)
g = g + 1
bot.run('token')
答案 0 :(得分:0)
@bot.event()
async def on_ready():
await someFunction()
async def someFunction():
# some Code
await someFunction() # Use recursion
bot.run("token")