我正在尝试做的事情:通过bot在其DMs中接收来自消息作者的响应
我的问题:在DMs中向Bot发送消息时,Bot没有响应我的期望。没有错误消息
代码:
@client.command()
async def test(ctx):
await ctx.send("Sending a dm now")
def check(message):
return message.author == ctx.author and message.channel == discord.channel.DMChannel
try:
await ctx.author.send("Say test: ")
response = await client.wait_for('message', check=check)
if response.content.lower() == 'test':
await ctx.send("Test successful")
elif response.content.lower() == 'banana':
await ctx.author.send("That works too")
except:
# do things here
图像:
(上图)尽管满足给定条件,但未给出响应
参考资料/我提到的其他问题:
您的支票有问题,如果您打印
message.channel
,您将得到:如果您打印
discord.channel.DMChannel
,您将获得:您会注意到它们是两种不同的东西,将支票更改为此应该可以解决问题:
相关问题 更多 >
编程相关推荐