Python discord.VoiceState() Examples
The following are 4
code examples of discord.VoiceState().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
discord
, or try the search function
.
Example #1
Source File: advanced.py From Wavelink with MIT License | 6 votes |
def on_voice_state_update(self, member: discord.Member, before: discord.VoiceState, after: discord.VoiceState): if member.bot: return player: Player = self.bot.wavelink.get_player(member.guild.id, cls=Player) if not player.channel_id or not player.context: player.node.players.pop(member.guild.id) return channel = self.bot.get_channel(int(player.channel_id)) if member == player.dj and after.channel is None: for m in channel.members: if m.bot: continue else: player.dj = m return elif after.channel == channel and player.dj not in channel.members: player.dj = member
Example #2
Source File: bot.py From Penny-Dreadful-Tools with GNU General Public License v3.0 | 5 votes |
def on_voice_state_update(self, member: Member, before: VoiceState, after: VoiceState) -> None: # pylint: disable=unused-argument # If we're the only one left in a voice chat, leave the channel guild = getattr(after.channel, 'guild', None) if guild is None: return voice = guild.voice_client if voice is None or not voice.is_connected(): return if len(voice.channel.voice_members) == 1: await voice.disconnect()
Example #3
Source File: listeners.py From predacogs with MIT License | 5 votes |
def on_voice_state_update( self, member, before: discord.VoiceState, after: discord.VoiceState ): if not after.channel: return guild = after.channel.guild bot_in_room = guild.me in after.channel.members if bot_in_room: self.upsert(rgetattr(member, "guild.id", -1), "users_joined_bot_music_room")
Example #4
Source File: sigma.py From apex-sigma-core with GNU General Public License v3.0 | 5 votes |
def on_voice_state_update(self, member, before, after): """ Starts events when a user changes their voice state. Such as connecting, disconnecting and moving between channels. :type member: discord.Member :type before: discord.VoiceState :type after: discord.VoiceState :param member: The member that changed their voice state. :param before: The member as they were before the change. :param after: The member as they are after the change. :return: """ if not member.bot: payload = VoiceStateUpdatePayload(self, member, before, after) self.loop.create_task(self.queue.event_runner('voice_state_update', payload))