【发布时间】:2021-10-21 08:57:40
【问题描述】:
我正在使用discord.ext.commands 制作一个不和谐的机器人。我做了一个命令,即使有人被禁止,也会不断地取消禁止人。这是代码:
@client.command(name="unban")
async def unban(ctx):
while True:
bans = await ctx.guild.bans()
if(len(bans)>0):
for ban in bans:
ctx.guild.unban(ban)
await asyncio.sleep(5)
但这是一个 while 循环,所以我想通过另一个命令(比如 stop_unban)终止这个函数。所以我想知道如何通过另一个函数(与stop_unban命令相关)来终止unban函数。
【问题讨论】:
标签: python asynchronous discord discord.py terminate