Exemplo n.º 1
0
async def join(ctx):
    """Makes Discobot join your current voice channel."""
    channel = ctx.message.author.voice_channel
    if channel is None:
        return
    if bot.is_voice_connected(channel.server):
        await bot.voice.disconnect()
    await bot.join_voice_channel(channel)
Exemplo n.º 2
0
async def join(ctx):
    """Makes Discobot join your current voice channel."""
    channel = ctx.message.author.voice_channel
    if channel is None:
        return
    if bot.is_voice_connected(channel.server):
        await bot.voice.disconnect()
    await bot.join_voice_channel(channel)
Exemplo n.º 3
0
async def play(ctx, uri: str):
    """Plays the track of your choice."""
    if not bot.is_voice_connected(ctx.message.server):
        return

    after = lambda: bot.loop.create_task(bot.change_status(game=game.Game()))

    match = re.match(constants.RE_ATTACHMENT_URI, uri)
    if match is not None:
        if not bot.config['attachments']['enabled']:
            await bot.say('Support for attachments is currently disabled.')
            return

        discriminator = match.group(1)
        filename = match.group(2)
        path = os.path.join('attachments', discriminator, filename)
        if not os.path.exists(path):
            await bot.say('That attachment does not exist!')
            return

        await bot.play_attachment(path, after=after)
        return

    match = re.match(constants.RE_YOUTUBE_URL, uri)
    if match is not None:
        if not bot.config['youtube']['enabled']:
            await bot.say('Support for YouTube is currently disabled.')
            return

        await bot.play_youtube(uri, after=after)
        return

    match = re.match(constants.RE_SOUNDCLOUD_URL, uri)
    if match is not None:
        if not bot.config['soundcloud']['enabled']:
            await bot.say('Support for SoundCloud is currently disabled.')
            return

        await bot.play_soundcloud(uri, after=after)
        return

    await bot.say('Invalid URI.')
Exemplo n.º 4
0
async def play(ctx, uri: str):
    """Plays the track of your choice."""
    if not bot.is_voice_connected(ctx.message.server):
        return

    after = lambda: bot.loop.create_task(bot.change_status(game=game.Game()))

    match = re.match(constants.RE_ATTACHMENT_URI, uri)
    if match is not None:
        if not bot.config['attachments']['enabled']:
            await bot.say('Support for attachments is currently disabled.')
            return

        discriminator = match.group(1)
        filename = match.group(2)
        path = os.path.join('attachments', discriminator, filename)
        if not os.path.exists(path):
            await bot.say('That attachment does not exist!')
            return

        await bot.play_attachment(path, after=after)
        return

    match = re.match(constants.RE_YOUTUBE_URL, uri)
    if match is not None:
        if not bot.config['youtube']['enabled']:
            await bot.say('Support for YouTube is currently disabled.')
            return

        await bot.play_youtube(uri, after=after)
        return

    match = re.match(constants.RE_SOUNDCLOUD_URL, uri)
    if match is not None:
        if not bot.config['soundcloud']['enabled']:
            await bot.say('Support for SoundCloud is currently disabled.')
            return

        await bot.play_soundcloud(uri, after=after)
        return

    await bot.say('Invalid URI.')
Exemplo n.º 5
0
async def resume(ctx):
    """Resumes the currently playing track."""
    if not bot.is_voice_connected(ctx.message.server):
        return
    if bot.player is not None:
        bot.player.resume()
Exemplo n.º 6
0
async def stop(ctx):
    """Stops the currently playing track."""
    if not bot.is_voice_connected(ctx.message.server):
        return
    if bot.player is not None:
        bot.player.stop()
Exemplo n.º 7
0
async def resume(ctx):
    """Resumes the currently playing track."""
    if not bot.is_voice_connected(ctx.message.server):
        return
    if bot.player is not None:
        bot.player.resume()
Exemplo n.º 8
0
async def stop(ctx):
    """Stops the currently playing track."""
    if not bot.is_voice_connected(ctx.message.server):
        return
    if bot.player is not None:
        bot.player.stop()