當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。