【发布时间】:2021-08-11 07:09:01
【问题描述】:
所以我正在制作一个机器人,比如向用户提问,我遇到了以下问题,我安装了所有必需的库并且它们可以工作
@client.command()
async def partner(ctx):
def check(m):
if m.channel == discord.channel.DMChannel and m.author == ctx.author:
return m.author == ctx.author and m.channel == discord.DMChannel
x = ["hello","hi"]
for i in x:
msg.content=msg.content.lower()
await discord.DMChannel.send(ctx.author,i)
try:
msg = await client.wait_for('message',timeout=60.0, check=check)
except asyncio.TimeoutError:
await discord.DMChannel.send(ctx.author,"Please dont take that long for your answer, be quicker next time")
return
else:
if msg.content =="cancel":
await discord.DMChannel.send(ctx.author,"Ok Cancelling partnership, you can still re-apply")
return
answers.append(msg.content)
但问题是,如果您在我的代码缩进中看到任何错误,我实际上也无法获得我想要的输出,因此我正在移动设备上执行此操作,并且。我检查了互联网上的所有东西,但没有一个对我有帮助,我很感谢你能给我的任何帮助
编辑后: 下面的答案是正确的,如果你们都想使用它,那就这样做吧
def check(m):
if m.author == ctx.author and isinstance(m.channel,discord.DMChannel):
return m.author == ctx.author
它有效。非常感谢您分享答案
【问题讨论】:
标签: python python-3.x discord.py