Python 正在等待消息,但bot没有响应 @client.command() @拥有\u权限(管理员=True) 异步def nuke(ctx,通道名称): channel\u id=int(“”.join(如果i.isdigit(),则i代表channel\u名称中的i) 现有\u通道=客户端。获取\u通道(通道\u id) 等待ctx发送(“请确认核武器:键入是或否”) def检查(m): 返回m.content==“是” msg=wait client.wait_for('message',check=check) 如果现有_通道不是无: 等待现有的\u channel.clone(reason=“Has nuked”) 等待现有的_通道。删除() 其他: wait ctx.send(未找到名为**{channel_name}**的频道) def检查: 返回s.content==“否” msg=wait client.wait_for('message',check=check) 等待ctx.发送(“核武器已被取消”)
我遇到的问题是: 一旦你说不,机器人应该取消命令,但它不会取消命令。如果您在说“否”之后立即说“是”,则bot仍将继续克隆并删除频道。也没有错误消息。如果你需要任何其他信息,请告诉我Python 正在等待消息,但bot没有响应 @client.command() @拥有\u权限(管理员=True) 异步def nuke(ctx,通道名称): channel\u id=int(“”.join(如果i.isdigit(),则i代表channel\u名称中的i) 现有\u通道=客户端。获取\u通道(通道\u id) 等待ctx发送(“请确认核武器:键入是或否”) def检查(m): 返回m.content==“是” msg=wait client.wait_for('message',check=check) 如果现有_通道不是无: 等待现有的\u channel.clone(reason=“Has nuked”) 等待现有的_通道。删除() 其他: wait ctx.send(未找到名为**{channel_name}**的频道) def检查: 返回s.content==“否” msg=wait client.wait_for('message',check=check) 等待ctx.发送(“核武器已被取消”),python,discord.py,Python,Discord.py,我遇到的问题是: 一旦你说不,机器人应该取消命令,但它不会取消命令。如果您在说“否”之后立即说“是”,则bot仍将继续克隆并删除频道。也没有错误消息。如果你需要任何其他信息,请告诉我 行msg=wait client.wait_for('message',check=check)暂停执行,直到满足条件m.content='yes'?这应该更好地发挥作用: @client.command() @has_permissions(administrator=True) async def nuke(c
行
msg=wait client.wait_for('message',check=check)
暂停执行,直到满足条件m.content='yes'
?这应该更好地发挥作用:
@client.command()
@has_permissions(administrator=True)
async def nuke(ctx, channel_name):
channel_id = int(''.join(i for i in channel_name if i.isdigit()))
existing_channel = client.get_channel(channel_id)
await ctx.send("Please confirm nuke: type yes or no")
def check(m):
return m.content == 'yes' or m.content == 'no'
msg = await client.wait_for('message', check=check)
if msg.content == 'yes':
if existing_channel is not None:
await existing_channel.clone(reason="Has been nuked")
await existing_channel.delete()
else:
await ctx.send(f'No channel named **{channel_name}** was found')
elif msg.content == 'no':
await ctx.send("Nuke has been canceled")