Python discord 模块,VoiceClient() 实例源码

我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用discord.VoiceClient()

项目:vlt-Music    作者:Mondanzo    | 项目源码 | 文件源码
def add(self, song_url: str, voice_client: discord.VoiceClient, user=None):
        try:
            song_player = await voice_client.create_ytdl_player(song_url, ytdl_options=ytdl_format_options)
        except youtube_dl.DownloadError:
            return youtube_dl.DownloadError
        except youtube_dl.SameFileError:
            return youtube_dl.SameFileError
        except youtube_dl.utils.ExtractorError:
            return youtube_dl.utils.ExtractorError
        except youtube_dl.utils.UnavailableVideoError:
            return youtube_dl.utils.UnavailableVideoError
        user_name = "********"
        if user is not None:
            user_name = user.display_name
        song = {"player": None, "url": song_player.url, "title": song_player.title,
                "uploader": song_player.uploader, "user": user_name}
        await self.__queue.put(song)
        return song

    # Get next song and delete it
项目:plumeria    作者:sk89q    | 项目源码 | 文件源码
def _wrap(o, transport):
    if isinstance(o, list) or isinstance(o, DICT_VALUES):
        return [_wrap(item, transport) for item in o]
    elif isinstance(o, tuple):
        return tuple([_wrap(item, transport) for item in o])
    elif isinstance(o, Client):
        return transport
    elif isinstance(o, _Server):
        return DiscordServer(o, transport)
    elif isinstance(o, _Channel):
        return DiscordChannel(o, transport)
    elif isinstance(o, _PrivateChannel):
        return DiscordChannel(o, transport)
    elif isinstance(o, _Message):
        return DiscordMessage(o, transport)
    elif isinstance(o, _Member):
        return DiscordWrapper(o, transport)
    elif isinstance(o, _User):
        return DiscordWrapper(o, transport)
    elif isinstance(o, VoiceClient):
        return DiscordWrapper(o, transport)
    elif isinstance(o, Enum):
        return str(o)

    return o
项目:vlt-Music    作者:Mondanzo    | 项目源码 | 文件源码
def pop(self, voice_client: discord.VoiceClient):
        item = await self.__queue.get()
        item['player'] = await voice_client.create_ytdl_player(item['url'], ytdl_options=ytdl_format_options)
        return item

    # Get if queue is empty
项目:Addon    作者:GitAcrown    | 项目源码 | 文件源码
def voice_client(self, server: discord.Server) -> discord.VoiceClient:
        return self.bot.voice_client_in(server)
项目:tmerc-cogs    作者:tmercswims    | 项目源码 | 文件源码
def voice_client(self, server: discord.Server) -> discord.VoiceClient:
        return self.bot.voice_client_in(server)
项目:tmerc-cogs    作者:tmercswims    | 项目源码 | 文件源码
def voice_client(self, server: discord.Server) -> discord.VoiceClient:
        return self.bot.voice_client_in(server)