【问题标题】:discord py bot send message more than one timediscord py bot 多次发送消息
【发布时间】:2021-06-17 17:46:54
【问题描述】:
这是我的代码:
@bot.command(pass_context = True)
async def spambot(ctx):
await ctx.author.send("message")
await ctx.send("check your dms")
这会发送消息,然后发送一个通知。如何多次重复此过程?
【问题讨论】:
标签:
python
discord
discord.py
【解决方案1】:
我假设你在问如何把它放在一个循环中。
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