【发布时间】:2020-04-07 18:52:48
【问题描述】:
所以,这段代码可能看起来很糟糕,这是因为它实际上很糟糕,但我花了几个小时寻找类似的代码,但找不到一个可以工作的代码。 我是这个不和谐机器人开发的初学者,听说不和谐需要“更新”代码,但我找不到任何可以帮助解决这个问题的东西。
@client.command()
async def role(ctx):
role = discord.utils.get(member.server.roles, id="id-here")
await bot.add_roles(member, role)
我也尝试了一个事件:(不工作)
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content == 'give me admin':
role = get(message.server.roles, id='also id here')
await client.add_roles(message.author, role)
【问题讨论】:
-
试试这个,特别是
add_roles一个:stackoverflow.com/questions/61008770/… -
谢谢,它成功了。你介意我根据你的代码回答我自己的问题吗?
-
完全没有,随意
标签: python discord discord.py