VoiceHandler.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:Sparcli 作者: 4Kaylum 项目源码 文件源码
def joinVC(self, toJoin, channel=None):
        '''
        Joins a given voice channel.
        Will join the VC of a member if a member is passed.
        '''

        if channel == None:
            channel = self.lastChannel

        # Join a channel if specified
        if type(toJoin) == Channel:
            loadedVC = self.sparcli.join_voice_channel(toJoin)
            self.voiceClient = loadedVC
            return loadedVC

        # No channel specified, join the user's VC
        memberVC = toJoin.voice.voice_channel
        if memberVC == None:
            await self.sparcli.send_message(channel, 'You aren\'t currently in a voice channel.')
            return False

        # Join the member's VC
        try:
            # Try to join
            loadedVC = await self.sparcli.join_voice_channel(memberVC)
            self.voiceClient = loadedVC
            return loadedVC

        except ClientException:
            # You're already in it
            loadedVC = self.sparcli.voice_client_in(toJoin.server)
            self.voiceClient = loadedVC
            return loadedVC

        else:
            # You can't join it
            await self.sparcli.send_message(channel, 'I am unable to join that voice channel.')
            return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号