1 回答

TA貢獻1998條經(jīng)驗 獲得超6個贊
你忘記了參數(shù)'member'
從文檔
async?def?on_voice_state_update(member,?before,?after)
之前和之后是 VoiceState,代表成員(在參數(shù)中)是否靜音、廣播等信息……
因此你不能從中檢索角色你必須從成員那里得到它
@client.event
async def on_voice_state_update(member, before, after):
? ? role = discord.utils.get(member.guild.roles, name="glosowy")
? ? if role: # verify their is a role with that name
? ? ? ? if not before.channel and after.channel: # check member just entered a channel
? ? ? ? ? ? await member.add_roles(role) #add role to it?
? ? ? ? elif before.channel and not after.channel: # check member just left a channel
? ? ? ? ? ? await member.remove_roles(role) # remove role to it
添加回答
舉報