繁体   English   中英

使用 discord.py 进行输入

[英]Taking input with discord.py

所以我正在用 discord.py 制作一个机器人,我留下了一个赏金说,任何能解决这个谜题的人都会得到 50 美元,现在我希望我的用户在 dms 中发布他们对机器人的答案,这是我写的代码!

@client.command()
async def answer(ctx, answer):
    print(Fore.LIGHTGREEN_EX + "[" + current_time + "] " + (ctx.author.name +"#"+ ctx.author.discriminator) + " Gave the Following Answer: " + answer)
    await ctx.author.send("**`Your Answer Has Been Submitted, Please Be Patient As We Review!`**")
    await ctx.author.send("Your Answer is: " + answer)

现在的问题是,它只需要第一个词作为答案,而我希望机器人将整个内容发送给我,我该怎么做?

我尝试使用诸如answer[0:]之类的字符串索引,还尝试将 str 添加到答案中,但没有任何效果...

由于您使用的是@client.command因此这记录在 Discord.py 的文档中(示例来自文档页面):

@bot.command()
async def test(ctx, *, arg):
    await ctx.send(arg)

在你的情况下,

@client.command()
async def answer(ctx, *, answer):
    print(Fore.LIGHTGREEN_EX + "[" + current_time + "] " + (ctx.author.name +"#"+ ctx.author.discriminator) + " Gave the Following Answer: " + answer)
    await ctx.author.send("**`Your Answer Has Been Submitted, Please Be Patient As We Review!`**")
    await ctx.author.send("Your Answer is: " + answer)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM