第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

TypeError: on_voice_state_update() 需要 2 個位置參數(shù)

TypeError: on_voice_state_update() 需要 2 個位置參數(shù)

楊魅力 2023-05-09 10:53:52
我正在嘗試制作一個機器人,讓成員在語音頻道上扮演角色,但由于某種原因它不起作用。這是代碼:@client.eventasync def on_voice_state_update(before, after):    role = discord.utils.get(after.server.roles, name="glosowy")    if not before.voice.voice_channel and after.voice.voice_channel:        await client.add_roles(after, role)    elif before.voice.voice_channel and not after.voice.voice_channel:        await client.remove_roles(after, role)這是我收到的錯誤:Ignoring exception in on_voice_state_updateTraceback (most recent call last):  File "C:\Users\aaa\AppData\Local\Programs\Python\Python38\lib\site-packages\discord\client.py", line 312, in _run_event    await coro(*args, **kwargs)TypeError: on_voice_state_update() takes 2 positional arguments but 3 were given
查看完整描述

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


查看完整回答
反對 回復(fù) 2023-05-09
  • 1 回答
  • 0 關(guān)注
  • 171 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號