@client.command()
async def makereactionrole(ctx):
await ctx.send('What would you like the title to be?')
title = ''
def check(msg):
return msg.author == ctx.author and mesg.channel == ctx.channel
title = msg.content
await ctx.send(title)discord.ext.commands.errors.CommandInvokeError:命令引发异常: HTTPException: 400坏请求(错误代码: 50006):无法发送空消息
试图做出这样的回答:“你想要这个头衔是什么?”一种将作为测试返回的变量。请帮帮忙。
发布于 2021-07-28 06:46:25
这里是一个例子,您需要使用wait_for。
import asyncio
@bot.command()
async def makereactionrole(ctx):
def author_and_channel(msg):
return msg.author == ctx.author and msg.channel == ctx.channel
await ctx.send("Please enter a title")
#timeout is in sec
try:
title_msg = await bot.wait_for('message',
check=author_and_channel,
timeout=5.0)
except asyncio.TimeoutError:
return await ctx.channel.send(f'Sorry, you took too long to respond')
title = title_msg.content
print(title)博士:Bot.wait_for
发布于 2021-07-28 06:49:17
在共享代码的最后一行
await ctx.send(title)它将title变量作为消息发送,但是由于共享代码的第三行中的title变量是空的。
title = ''这就是问题出现的原因。
https://stackoverflow.com/questions/68554940
复制相似问题