Discord.py在命令后侦听消息

Discord.py在命令后侦听消息,discord.py,Discord.py,我一直在尝试创建一个bot命令,在命令发送后侦听消息。这意味着用于创建命令作者的概要文件,以便稍后存储在json文件中 async def create(ctx): await ctx.send("You will be asked a series of questions to create your Profile. If you accidentally typed this wait 15 seconds for it to cancel.") me

我一直在尝试创建一个bot命令,在命令发送后侦听消息。这意味着用于创建命令作者的概要文件,以便稍后存储在json文件中

async def create(ctx):
    await ctx.send("You will be asked a series of questions to create your Profile. If you accidentally typed this wait 15 seconds for it to cancel.")
    message = await client.wait_for('message',check=None,timeout=15)
    await ctx.send(message) #used to check what message is holding

虽然上面的代码可以正常工作,但它不能像我希望的那样工作,它会发回服务器、成员、频道、消息和作者的id以及其他信息。而不是由命令作者保存回复。

因此,您希望它存储用户的输入数据,并将其作为访问表单附加:

它接收用户的输入消息,并将其附加到他们回复的消息中,如下所示:

q_list = [
    'Your question 1',
    'Your question 2',
    'Your question 3']

a_list = []


@client.command()
async def create(ctx):

        await ctx.send("You will be asked a series of questions to create your Profile. If you accidentally typed this wait 15 seconds for it to cancel.")

        a_list = []
        submit_channel = client.get_channel(CHANNEL_ID_FOR_SUBMISSIONS)
        channel = await ctx.author.create_dm()

        def check(m):
                return m.content is not None and m.channel == channel

        for question in q_list:
                await asyncio.sleep(3)
                await channel.send(question)
                msg = await client.wait_for('message', check=check)
                a_list.append(msg.content)

        submit_wait = True
        while submit_wait:
                await channel.send(
                    'You have completed the interview, type ``submit`` to confirm')
                msg = await client.wait_for('message', check=check)
                if "submit" in msg.content.lower():
                        submit_wait = False
                        answers = "\n".join(f'{a}. {b}' for a, b in enumerate(a_list, 1))
                        submit_msg = f'''**Submission - Created by {msg.author.mention}** \n{answers}'''
                        await submit_channel.send(submit_msg)