!getuser
不和チャンネルのコマンドで特定のロールからメンバーリストを取得する方法。
@bot.command(pass_context=True)
async def getuser(ctx):
ボットはIDで返信します
1. @user1#123
2. @user2#123
リライトブランチは属性を提供しますRole.members
。
非同期ブランチでは、サーバーのすべてのメンバーをループして、それらの役割を確認する必要があります。
@bot.command(pass_context=True)
async def getuser(ctx, role: discord.Role):
role = discord.utils.get(ctx.message.server.roles, name="mod")
if role is None:
await bot.say('There is no "mod" role on this server!')
return
empty = True
for member in ctx.message.server.members:
if role in member.roles:
await bot.say("{0.name}: {0.id}".format(member))
empty = False
if empty:
await bot.say("Nobody has the role {}".format(role.mention))
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加