这是我的代码:
@bot.command(pass_context = True)
async def spambot(ctx):
await ctx.author.send("message")
await ctx.send("check your dms")
这会发送消息,然后发送一条通知。如何多次重复此过程?
答案 0 :(得分:0)
我假设您是在问如何将其放入循环中。
import asyncio
@bot.command(pass_context=True)
async def spambot(ctx):
for i in range(10): #you can change 10 to any number, this loops the command 10 times
await ctx.author.send("message")
await ctx.send("check your dms")
await asyncio.sleep(1) #this adds a delay so your bot doesn't get rate limited