Ejemplo n.º 1
0
    async def nowPlaying(self, ctx):
        """Get the current position of song [np]"""
        player = self.bot.lavalink.player_manager.get(ctx.guild.id)

        if not (await self.can_interact(ctx)):
            return

        # Use format_time from lavalink.utils to convert milliseconds to HH:MM:SS
        await ctx.send(embed=create_embed("Now Playing", str(player.current.title) +":\n" \
         + lavalink.format_time(player.position) + " / " \
         + lavalink.format_time(player.current.duration)))
Ejemplo n.º 2
0
 async def now(self, ctx):
     player = self.lavalink.player_manager.get(ctx.guild.id)
     if not player.current:
         return await ctx.send('Ничего не играет')
     position = format_time(player.position)
     if player.current.stream:
         duration = '🔴 LIVE'
     else:
         duration = format_time(player.current.duration)
     song = f'[{player.current.title}]({player.current.uri})\n({position}/{duration})'
     embed = Embed(color=get_embed_color(player.current.uri),
                   title='Сейчас играет',
                   description=song)
     await ctx.send(embed=embed)
Ejemplo n.º 3
0
 async def 지금곡(self, ctx):
     player = self.bot.lavalink.player_manager.get(ctx.guild.id)
     if not player.current:
         return await ctx.send('Nothing playing.')
     position = lavalink.format_time(player.position)
     if player.current.stream:
         duration = '🔴 LIVE'
     else:
         duration = lavalink.format_time(player.current.duration)
     song = f'**[{player.current.title}]({player.current.uri})**\n({position}/{duration})'
     embed = discord.Embed(color=discord.Color.blurple(),
                           title='Now Playing', description=song)
     sans = player.current.uri.split('/')[-1].split('?v=')[-1]
     embed.set_image(url=f'https://i.ytimg.com/vi/{sans}/hqdefault.jpg')
     await ctx.send(embed=embed)
Ejemplo n.º 4
0
    async def now(self, ctx):
        player = self.bot.music.player_manager.get(ctx.guild.id)
        song = 'Nothing'

        if player.current:
            position = lavalink.format_time(player.position)
            if player.current.stream:
                duration = 'LIVE'
            else:
                duration = lavalink.format_time(player.current.duration)
            song = f'**[{player.current.title}]({player.current.uri})**\n({position}/{duration})'

        embed = Embed(colour=ctx.guild.me.top_role.colour,
                      title='Reproduciendo', description=song)
        await ctx.send(embed=embed)
Ejemplo n.º 5
0
    async def savetodm(self, ctx):
        player = self.bot.lavalink.player_manager.get(ctx.guild.id)
        if player.current:
            if player.current.stream:
                dur = 'Live'
            else:
                dur = lavalink.format_time(
                    player.current.duration).lstrip('00:')
            song = f'[{player.current.title}]({player.current.uri})'
            em = discord.Embed(colour=discord.Colour(0x59FFC8),
                               description=song)
            em.set_author(name="Now Playing 🎵",
                          icon_url="https://i.ibb.co/DGsmTvh/star.gif")
            em.set_thumbnail(
                url=
                f"http://i.ytimg.com/vi/{player.current.identifier}/hqdefault.jpg"
            )
            em.add_field(name='Channel', value=player.current.author)
            em.add_field(name='Duration', value=dur)

            user = ctx.author
            await user.send(embed=em)
            await ctx.send(
                f"Current song has been sent to you {ctx.author.mention} :floppy_disk:"
            )
        else:
            await ctx.send('Not playing anything :mute:')
Ejemplo n.º 6
0
    async def play(self, ctx, *, query):
        player = self.bot.lavalink.player_manager.get(ctx.guild.id)

        query = query.strip('<>')

        if not query.startswith('http'):
            query = f'ytsearch:{query}'

        results = await player.node.get_tracks(query)

        if not results or not results['tracks']:
            return await ctx.send(
                'Song not found :x: Please try again :mag_right:')

        em = discord.Embed(colour=discord.Colour(0x59FFC8))

        if results['loadType'] == 'PLAYLIST_LOADED':
            tracks = results['tracks']

            for track in tracks:
                # Add all of the tracks from the playlist to the queue.
                player.add(requester=ctx.author.id, track=track)

            em.title = 'Playlist Enqueued!'
            em.description = f'{results["playlistInfo"]["name"]} - {len(tracks)} tracks'
        else:
            track = results['tracks'][0]
            em.title = 'Track Enqueued'
            em.description = f'[{track["info"]["title"]}]({track["info"]["uri"]})'
            em.set_thumbnail(
                url=
                f"http://i.ytimg.com/vi/{track['info']['identifier']}/hqdefault.jpg"
            )

            em.add_field(name='Channel', value=track['info']['author'])
            if track['info']['isStream']:
                duration = 'Live'
            else:
                duration = lavalink.format_time(
                    track['info']['length']).lstrip('00:')
            em.add_field(name='Duration', value=duration)

            track = lavalink.models.AudioTrack(track,
                                               ctx.author.id,
                                               recommended=True)
            player.add(requester=ctx.author.id, track=track)

        msg = await ctx.send(embed=em)

        if not player.is_playing:
            await player.play()
            await player.reset_equalizer()
            await msg.delete(delay=1)
            await self.now(ctx)
            await self.bot.change_presence(activity=discord.Activity(
                type=discord.ActivityType.listening, name=player.current.title)
                                           )
Ejemplo n.º 7
0
    async def now(self, ctx):
        player = self.bot.lavalink.player_manager.get(ctx.guild.id)
        song = 'Nothing'

        if player.current:
            if player.current.stream:
                dur = 'LIVE'
                pos = ''
                count = total = 1
            else:
                count = player.position
                pos = lavalink.format_time(count)
                total = player.current.duration
                dur = lavalink.format_time(total)
                if pos == dur:  # When called immediatly after enqueue
                    count = 0
                    pos = '00:00:00'
                dur = dur.lstrip('00:')
                pos = pos[-len(dur):]
            bar_len = 30  # bar length
            filled_len = int(bar_len * count // float(total))
            bar = '═' * filled_len + '◈' + '─' * (bar_len - filled_len)
            song = f'[{player.current.title}]({player.current.uri})\n`{pos} {bar} {dur}`'

            em = discord.Embed(colour=discord.Colour(0x59FFC8),
                               description=song)
            em.set_author(name="Now Playing 🎵",
                          icon_url="https://i.ibb.co/DGsmTvh/star.gif")
            em.set_thumbnail(
                url=
                f"http://i.ytimg.com/vi/{player.current.identifier}/hqdefault.jpg"
            )
            requester = ctx.guild.get_member(player.current.requester)
            em.set_footer(text=f"Requested by: {requester}",
                          icon_url=requester.avatar_url)

            await ctx.send(embed=em)
            await self.bot.change_presence(activity=discord.Activity(
                type=discord.ActivityType.listening, name=player.current.title)
                                           )
        else:
            await ctx.send('Not playing anything :mute:')