我无法让我的机器人添加角色。我在这里做什么错了?
class MyClient(discord.Client):
async def on_voice_state_update(member, before, after):
role = get(member.server.roles, name="babbelaar")
if after.channel is None:
member.add_roles([role.id])
else:
member.remove_roles([role.id])
我希望加入语音通道的用户获得特定角色,并在用户离开语音通道后删除该角色
答案 0 :(得分:0)
您需要path ='C:/Users/Name/Desktop/twitbot/home/gay'
files = os.listdir(path)
index = random.randrange(0, len(files))
message = "Picture of the moment!"
file = path + '/' + files[index]
# or you can use file = os.path.join(os.path.realpath(path), files[index])
with open(file, 'rb') as photo:
twitter.update_status_with_media(status=message, media=photo)
添加/删除角色,并将角色作为await
对象的参数列表传递(而不是通过列表):
Role