我想让它停止,我的意思是一个单独的命令(~cdstop)会取消倒计时。在import discord
import asyncio
counter_channel = None
async def ex(args, message, client, invoke):
global counter_channel
if counter_channel is not None:
await client.send_message(message.channel, embed=discord.Embed(color=discord.Color.red(), "There is a counter in {}".format(counter_channel.mention)))
return
counter_channel = message.channel
await client.send_message(message.channel, "5 Minutes")
await asyncio.sleep(60)
await client.send_message(message.channel, "4 Minutes")
await asyncio.sleep(60)
await client.send_message(message.channel, "3 Minutes")
await asyncio.sleep(60)
await client.send_message(message.channel, "2 Minutes")
await asyncio.sleep(60)
await client.send_message(message.channel, "1 Minutes")
await asyncio.sleep(30)
await client.send_message(message.channel, "30 Seconds")
await asyncio.sleep(15)
await client.send_message(message.channel, "15 Seconds")
await asyncio.sleep(10)
await client.send_message(message.channel, "5 Seconds")
counter_channel = None
我的想法是,在每个print语句之后,它会检查用户是否输入了~cdstop,然后从函数中中断。我认为它会起作用,但我不知道它是否有效,因为我知道它会扰乱双倒计时的检查。在
编辑
调用文件的代码:
^{pr2}$