#VoiceState

1 messages · Page 1 of 1 (latest)

lunar mountain
#

How can i get print(hikari.VoiceState.user_id) to return the id ,not <member 'user_id' of 'VoiceState' objects>?

dusty sun
#

you should use the instancce of the voicestate event and not the class

lunar mountain
dusty sun
#

you need to listen to the VoiceStateUpdateEvent event

#

as in, subscibe to it

#

the event contains the new state and the old state of the user which fired the event (and also the user_id ofc)

dusty sun
#

can you show your code then?

lunar mountain
#

sure

#

@bot.listen(hikari. VoiceStateUpdateEvent )
async def vc_join(event):
print(hikari.VoiceState.user_id)

#

sorry

#

it was VoiceStateUpdateEvent

#

just tested smth

dusty sun
#

yes, and then you can use event.old_state.user_id and/or event.state.user_id

lunar mountain
#

ok thanks

dusty sun
#

and other properties/methods that the VoiceState class provides ofc

lunar mountain
dusty sun
#

check the old_state and the new state for a channel

#

but remember, when they change channel, they still join a new channel 😉

lunar mountain
#

what would event.old_state.user_id return? cause for me it returns Traceback (most recent call last):

  print(event.old.state.user_id)
        ^^^^^^^^^
AttributeError: 'VoiceStateUpdateEvent' object has no attribute 'old'```
am i missing anything?
dusty sun
#

its old_state

lunar mountain
#

oh mb