为提醒命令添加限制|不和谐

时间:2020-07-27 06:39:43

标签: discord.py discord.py-rewrite

所以我有一个简单的提醒脚本asyncio,我想知道是否可以增加一个提醒时间限制,我在想60分钟左右。这是我的代码:

@client.command()
async def remind(ctx, mins : int, reminder):
    embed=discord.Embed(title='Reminder set', description=f"{ctx.author.mention}, I have set a reminder for {mins} minutes with the reminder being {reminder}", colour=discord.Colour.blurple())
    embed.timestamp = ctx.message.created_at
    await ctx.send(embed=embed)

    counter = 0
    while counter <= int(mins):
        counter += 1
        await asyncio.sleep(60)

        if counter == int(mins):
            await ctx.send(f"{ctx.author.mention}, your reminder for {reminder} with a time of {mins} minutes has gone off.")
            break

1 个答案:

答案 0 :(得分:0)

如果您想将mins的限制设置为 60 ,则可以在开始{{之前,先检查mins> 60 1}}循环。

while