📜  discord python application bot - Python代码示例

📅  最后修改于: 2022-03-11 14:47:09.227000             🧑  作者: Mango

代码示例1
q_list = [
    'What is your favorite color?',
    'Is the Sky Blue?',
    'Am I the best bot ever?'
]

a_list = []


@client.command(aliases=['staff-application'])
async def staff_application(ctx):
    a_list = []
    submit_channel = client.get_channel()
    channel = await ctx.author.create_dm()

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

    for question in q_list:
        sleep(.5)
        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('End of questions - "submit" to finish')
        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'Application from {msg.author} \nThe answers are:\n{answers}'
            await submit_channel.send(submit_msg)