music.py 文件源码

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

项目:Red_Star 作者: medeor413 项目源码 文件源码
def connect(self, data):
            """
            Connect to a channel in the specific server, or move if already in vc
            :param: false or default channel id
            :param data: message data to get author out of
            :return: True if connected, False if something went wrong
            """
            try:
                m_channel = self.parent.channel_manager.get_channel(self.guild, "voice_music")
            except ChannelNotFoundError:
                m_channel = None
            except AttributeError:
                self.parent.logger.error("Failed to get channel.")
                m_channel = None
            if not m_channel and data.author.voice and data.author.voice.channel:
                m_channel = data.author.voice.channel
            elif not m_channel:
                raise UserPermissionError("Must be in voice chat.")
            self.vc = data.guild.voice_client
            if self.vc:
                await self.vc.move_to(m_channel)
                return m_channel
            perms = m_channel.permissions_for(self.guild.me)
            if perms.connect and perms.speak and perms.use_voice_activation:
                try:
                    self.vc = await m_channel.connect()
                    if self.queue:
                        await self.skip_song(data)
                    return m_channel
                except(InvalidArgument, ClientException):
                    self.parent.logger.exception("Error connecting to voice chat. ", exc_info=True)
                    return False
            else:
                return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号