#VoiceStateUpdate event

1 messages · Page 1 of 1 (latest)

abstract flax
#

you can just get the amount of member voicestates in the channel

#

get the voice channel ID from one of the states, (old/new)

#

then you can do bot.cache.get_voice_states_view_for_channel(guild_id, channel_id)

#

you can call len(...) on the whole thing

#

and that will give you the amount of members in the channel

visual vine
#

How to do it inside the plugin?

abstract flax
#

Show your code

visual vine
visual vine
# abstract flax Show your code
from lightbulb import Plugin
from hikari import (
    VoiceStateUpdateEvent
)
from config import config

plugin = Plugin('voiceStateUpdate')

@plugin.listener(VoiceStateUpdateEvent)
async def voiceStateUpdate(event: VoiceStateUpdateEvent):
    if event.state.channel_id == config['voice_create_id']:
        private_voice = await event.state.member.get_guild().create_voice_channel(f'Канал {event.state.member.username}', category = config['voice_category_id'])
        
        await event.state.member.edit(voice_channel = private_voice)
    
    if event.old_state != None:
        print(event.state.members)

def load(client) -> None:
    client.add_plugin(plugin)


def unload(client) -> None:
    client.remove_plugin(plugin)
abstract flax
#

You can access the cache from plugin I'm pretty sure

buoyant bolt
#

yeah, from plugin.bot/plugin.app