[英]Discord.py ask for reply from people with specific role
@bot.command(aliases=['writing'])
async def shiritori(ctx):
def check(msg):
return msg.author == ctx.author and msg.channel == ctx.channel
while True:
msg = await bot.wait_for('message', check=check)
await ctx.send(str(msg))
This code wait for user message input and resend the input message to the chat.此代码等待用户消息输入并将输入消息重新发送到聊天。 But the code only replies to the person who started the command using '/writing'.但是代码只回复使用“/writing”启动命令的人。 How to make the code to reply to anybody who has discord role '@writer' after anyone starts the command?在任何人启动命令后,如何使代码回复具有不和谐角色“@writer”的任何人?
You should change your if
statement in your check()
function and check if message author have @writer
role:您应该在check()
函数中更改if
语句并检查消息作者是否具有@writer
角色:
@bot.command(aliases=['writing'])
async def shiritori(ctx):
def check(msg):
return msg.channel == ctx.channel and '@writer' in [x.name for x in msg.author.roles]
while True:
msg = await bot.wait_for('message', check=check)
await ctx.send(str(msg))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.