【发布时间】:2020-11-24 23:52:48
【问题描述】:
我需要我的机器人等待多个用户输入。例如
如果我在 discord 服务器中调用命令 ('!invite @user1 @user2 @user3')!
它应该等到所有提到的用户说"@mentionme accept"
现在的问题是,我可以做一次('!invite @user1'),但我不能为多个用户做。
这是我的代码:
@client.command()
async def invite(ctx,*,message):
mentioned_users = [member for member in message.mentions]#get all mentioned users
def check(message: discord.Message):
return message.channel == ctx.channel and message.author.id in mentioned_users and message.content == f"{ctx.author.mention} accept"
msg = await client.wait_for('message', check=check,timeout=40.0)#wait_for
await ctx.channel.send(f'{member.mention} accepted the invitation!')
它只适用于一次提及!有没有其他方法可以为多个用户使用wait_for 功能?
【问题讨论】:
标签: python discord discord.py discord.py-rewrite