当前位置: 首页>>代码示例>>Python>>正文


Python discord.VoiceState方法代码示例

本文整理汇总了Python中discord.VoiceState方法的典型用法代码示例。如果您正苦于以下问题:Python discord.VoiceState方法的具体用法?Python discord.VoiceState怎么用?Python discord.VoiceState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在discord的用法示例。


在下文中一共展示了discord.VoiceState方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: on_voice_state_update

# 需要导入模块: import discord [as 别名]
# 或者: from discord import VoiceState [as 别名]
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 
开发者ID:PythonistaGuild,项目名称:Wavelink,代码行数:24,代码来源:advanced.py

示例2: on_voice_state_update

# 需要导入模块: import discord [as 别名]
# 或者: from discord import VoiceState [as 别名]
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() 
开发者ID:PennyDreadfulMTG,项目名称:Penny-Dreadful-Tools,代码行数:13,代码来源:bot.py

示例3: on_voice_state_update

# 需要导入模块: import discord [as 别名]
# 或者: from discord import VoiceState [as 别名]
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") 
开发者ID:PredaaA,项目名称:predacogs,代码行数:11,代码来源:listeners.py

示例4: on_voice_state_update

# 需要导入模块: import discord [as 别名]
# 或者: from discord import VoiceState [as 别名]
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)) 
开发者ID:lu-ci,项目名称:apex-sigma-core,代码行数:17,代码来源:sigma.py


注:本文中的discord.VoiceState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。