从一个命令获得更多输入 (discord.py)
get more input from one command (discord.py)
我正在尝试制作一个嵌入系统,该系统会询问多个问题,然后将它们放在一起并发送带有所有给定信息的嵌入,但我不知道如何在一个命令中获取多个输入。
this image maybe can help understanding my question
谢谢
根据我从你的问题中了解到的情况,你只是在检查 m.content == "hello"
的一种可能输入。您可以删除它或添加 in
语句。请查看下面修改后的代码。
@commands.command()
async def greet(ctx):
await ctx.send("Say hello!")
def check(m):
return m.channel == channel # only check the channel
# alternatively,
# return m.content.lower() in ["hello", "hey", "hi"] and m.channel == channel
msg = await bot.wait_for("message", check=check)
await ctx.send(f"Hello {msg.author}!")
如果是新编辑的问题,您可以访问discord.Message
class from the msg
variable. For example, you can access the message.content
。请查看下面的代码片段。
@commands.command()
async def test(ctx):
def check(m):
return m.channel == ctx.channel and m.author == ctx.author
# return message if sent in current channel and author is command author
em = discord.Embed()
await ctx.send("Title:")
msg = await bot.wait_for("message",check=check)
em.title = msg.content
# in this case, you can continue to use the same check function
await ctx.send("Description:")
msg = await bot.wait_for("message",check=check)
em.description = msg.content
await ctx.send(embed=em)
我正在尝试制作一个嵌入系统,该系统会询问多个问题,然后将它们放在一起并发送带有所有给定信息的嵌入,但我不知道如何在一个命令中获取多个输入。
this image maybe can help understanding my question
谢谢
根据我从你的问题中了解到的情况,你只是在检查 m.content == "hello"
的一种可能输入。您可以删除它或添加 in
语句。请查看下面修改后的代码。
@commands.command()
async def greet(ctx):
await ctx.send("Say hello!")
def check(m):
return m.channel == channel # only check the channel
# alternatively,
# return m.content.lower() in ["hello", "hey", "hi"] and m.channel == channel
msg = await bot.wait_for("message", check=check)
await ctx.send(f"Hello {msg.author}!")
如果是新编辑的问题,您可以访问discord.Message
class from the msg
variable. For example, you can access the message.content
。请查看下面的代码片段。
@commands.command()
async def test(ctx):
def check(m):
return m.channel == ctx.channel and m.author == ctx.author
# return message if sent in current channel and author is command author
em = discord.Embed()
await ctx.send("Title:")
msg = await bot.wait_for("message",check=check)
em.title = msg.content
# in this case, you can continue to use the same check function
await ctx.send("Description:")
msg = await bot.wait_for("message",check=check)
em.description = msg.content
await ctx.send(embed=em)