亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

正在等待消息,但機器人沒有響應

正在等待消息,但機器人沒有響應

PHP
縹緲止盈 2023-11-09 16:54:08
@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'    msg = await client.wait_for('message', check=check)    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')    def check(s):        return s.content == 'no'    msg = await client.wait_for('message', check=check)    await ctx.send("Nuke has been canceled")我遇到的問題:一旦你說不,機器人應該取消命令,但它不會取消命令。如果您在說“不”后立即說“是”,機器人無論如何都會繼續克隆并刪除頻道。也沒有錯誤消息。如果您需要任何其他信息,請告訴我。
查看完整描述

1 回答

?
幕布斯6054654

TA貢獻1876條經驗 獲得超7個贊

該行不會暫停執行直到滿足msg = await 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")


查看完整回答
反對 回復 2023-11-09
  • 1 回答
  • 0 關注
  • 127 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號