本文介绍了当我回答“是"时,什么都没有发生?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,这是我的代码:

This is my code so far:

    @commands.command()
    async def destroy(self, ctx):
        def check(m):
            em = discord.Embed()
            return em.author == ctx.author and m.channel == ctx.channl

        await ctx.message.delete()
        em = discord.Embed(color=15859772, title = ":rotating_light: WARNING WARNING :rotating_light:", description=f"{ctx.author.mention} Are you sure you want to run this command? yes/no")
        await ctx.send(embed=em)
        # for user input
        response = await self.client.wait_for('message', check=check)

        if response.content.lower() == 'yes':
            await ctx.send("Done")
        else:
            await ctx.send("Canceled")

不确定出了什么问题.但是,如果我回答,则什么都不会发送,并且没有错误?

Not sure what has gone wrong. But if I respond with yes nothing gets sent and I get no errors?

推荐答案

您的 check 对我来说毫无意义.你为什么要在里面放一个嵌入物?

Your check makes no sense to me. Why do you put an embed in there?

尝试以下一种方法:

        def check(m):
            return m.author == ctx.author and m.channel == ctx.message.channel

这将检查命令的作者是否在正确的通道中进行响应.

This will check if the author of the command is responding in the correct channel.

如评论中所述,以下代码对我来说很好:

@client.command() # As you use client.wait_for
async def destroy(ctx):
    def check(m):
        return m.author == ctx.author and m.channel == ctx.message.channel

    await ctx.message.delete()
    em = discord.Embed(color=15859772, title=":rotating_light: WARNING WARNING :rotating_light:",
                        description=f"{ctx.author.mention} Are you sure you want to run this command? yes/no")
    await ctx.send(embed=em)
    # for user input
    response = await client.wait_for('message', check=check)

    if response.content.lower() == 'yes':
        await ctx.send("Done")
    else:
        await ctx.send("Canceled")

如果您仍然有错误,我认为您使用的是错误的方式/定义错误的东西 commands.command .

这篇关于当我回答“是"时,什么都没有发生?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 23:54