我有一个简单的discord.py机器人,它几乎可以算出用户想要的任何数字。到目前为止,命令如下所示:
@bot.command()
async def count(ctx, startNum, endNum):
startNum = int(startNum)
endNum = int(endNum)
currentNum = startNum
if startNum > endNum:
await ctx.send("nice try, i'm not counting backwards")
while currentNum < (endNum + 1) or startNum < endNum:
await ctx.send(ctx.message.author.name + ": " + str(currentNum))
currentNum += 1
await ctx.send(ctx.message.author.mention + " I've finished counting to " + str(endNum))
假设您运行count 10
,它将显示
username: 1
username: 2
username: 3
...
username: 10
我想创建一个几乎允许用户取消一个特定计数器而不取消其他任何计数器的命令。
最好,每个计数器都显示一个单独的计数器ID,然后您可以使用cancel ID
之类的命令将其取消。看起来像:
> count 1 50
CounterID: 1
CounterID: 2
CounterID: 3
> cancel CounterID
CounterID has been cancelled
这怎么办?
答案 0 :(得分:0)
在while循环中,您可以添加一个超时时间为1秒的.table-toolbar {
height: 80px !important;
padding-left: 24px !important;
min-height: 80px !important;
}
.sticky-top {
top: 0 !important;
z-index: 1000 !important; // This only makes it appear above or below the table
position: sticky;
}
事件:
wait_for
尽管该示例不允许取消特定计数器(除了用户自己的计数器)。如果您有一些数据库(例如json,sqlite,mongodb等),则可以为每个用户存储当前的计数器ID。
参考: