所以我想做一个命令,将角色分配给用户,但我不希望它是消息作者。有人能建议我怎么做吗?谢谢!你知道吗
这是你的名字消息作者代码的版本!你知道吗
if message.author == client.user:
return
if message.content.upper().startswith('!ROLE ADMIN', userID):
role = get(message.server.roles, id="517064875134943262")
userID = message.author.id
if not "343249790047485952" in [role.id for role in
message.author.roles]:
return
elif "517064875134943262" in [role.id for role in message.author.roles]:
await client.send_message(message.channel, 'You are already an admin
<@%s>' % (userID))
else:
await client.add_roles(message.author, role)
await client.send_message(message.channel, 'Admin given to <@%s>' %
(userID))
有两种方法:
最简单的方法是使用带有converter的
discord.ext.commands
扩展。你知道吗这使您可以通过使用其名称/提及来指定要赋予的角色:
!role @AdminRole @User
如果您想继续使用} 以获取消息中提到的用户列表。你知道吗
on_message
,还可以访问^{相关问题 更多 >
编程相关推荐