如何在 discord.py 中的特定时间间隔后向用户发送直接消息?
How can I send a direct message to a user after a certain interval in discord.py?
我想创建一个命令,让机器人在一定时间间隔(比如 10 秒)后向消息作者发送一条私信。
假设您希望在命令发送后执行:
import asyncio # for the sleep statement
@bot.command()
async def messageme(ctx):
await asyncio.sleep(10)
await ctx.author.send("This is my DM to you!")
参考文献:
我想创建一个命令,让机器人在一定时间间隔(比如 10 秒)后向消息作者发送一条私信。
假设您希望在命令发送后执行:
import asyncio # for the sleep statement
@bot.command()
async def messageme(ctx):
await asyncio.sleep(10)
await ctx.author.send("This is my DM to you!")
参考文献: