【问题标题】:Discord.py is there a way to split a command into multiple messages?Discord.py 有没有办法将命令拆分为多条消息?
【发布时间】:2020-11-12 16:22:22
【问题描述】:

例如,如果一个命令有多个参数,例如:

@client.command()
async def command(ctx, channel, time, prize):
     //code

如何让它在每条消息中要求不同的参数?像这样的东西: 机器人:什么渠道? 用户:(频道名称) 博特:多长时间? 用户:(时间) 博特:奖品是什么? 用户:(奖品)

如果有帮助,我正在制作赠品机器人。

【问题讨论】:

    标签: python discord.py


    【解决方案1】:

    使用wait_for。您甚至可以指定机器人应该等待多长时间。

    例子:

    @client.command()
    async def some_command_name(ctx):
        def check(m):
            return m.author == ctx.author and m.channel == ctx.channel
        try:
            await ctx.send("Channel?")
            channel = await client.wait_for('message', check=check, timeout=60)
            await ctx.send("Time?")
            time    = await client.wait_for('message', check=check, timeout=60)
            await ctx.send("Prize?")
            prize   = await client.wait_for('message', check=check, timeout=60)
        except asyncio.TimeoutError:
            # do something
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-06-11
      • 1970-01-01
      • 2020-10-17
      • 2021-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多