我想检查某人是否有角色,但是在 on message 函数中我不能传递除消息之外的任何其他内容,否则它将无法工作。
@client.event
async def on_message(message):
print("Test Success")
msg = message.content
member = message.author.id
print(message.author.id)
if message.author == client.user:
return # Do not check the bots messages
if "" in message.content:
await message.channel.send('Shut The Fuck Up', mention_author=True)
return
client.run('TOKEN')
答案 0 :(得分:0)
你的问题不清楚,如果作者有角色,我假设你想做一些事情。
async def on_message(message):
#other stuff
role = discord.utils.get(message.guild.roles, name='RoleName')
if role in message.author.roles:
# do stuff
await message.channel.send('You have the role `RoleName`')
参考文献:-