[英]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.