Musicbot: Please add song url to now playing command

Created on 13 Jul 2017  ·  8Comments  ·  Source: Just-Some-Bots/MusicBot

See title

All 8 comments

image
like this ?

Yeah something like that. I tried doing it myself:

image

But I didn't do it right and it sometimes displayed the wrong link.

async def cmd_np(self, player, channel, server, message):
    """
    Usage:
        {command_prefix}np

    Displays the current song in chat.
    """

    if player.current_entry:
        if self.server_specific_data[server]['last_np_msg']:
            await self.safe_delete_message(self.server_specific_data[server]['last_np_msg'])
            self.server_specific_data[server]['last_np_msg'] = None

        # TODO: Fix timedelta garbage with util function
        song_progress = ftimedelta(timedelta(seconds=player.progress))
        song_total = ftimedelta(timedelta(seconds=player.current_entry.duration))

        streaming = isinstance(player.current_entry, StreamPlaylistEntry)
        prog_str = ('`[{progress}]`' if streaming else '`[{progress}/{total}]`').format(
            progress=song_progress, total=song_total
        )
        prog_bar_str = ''

        # percentage shows how much of the current song has already been played
        percentage = 0.0
        if player.current_entry.duration > 0:
            percentage = player.progress / player.current_entry.duration
        """
        This for loop adds  empty or full squares to prog_bar_str (it could look like
        [■■■■■■■■■■□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□]
        if for example the song has already played 25% of the songs duration
        """
        progress_bar_length = 37
        for i in range(progress_bar_length):
            if (percentage < 1 / progress_bar_length * i):
                prog_bar_str += '▁'
            else:
                prog_bar_str += '▂'

        action_text = 'Streaming' if streaming else 'Playing'

        if player.current_entry.meta.get('channel', False) and player.current_entry.meta.get('author', False):
            np_text = "**Song:** [ <{url}> ] queued by **{author}** \n```{progress} Song: {title}  \n {progress_bar}```".format(

                action=action_text,
                title=player.current_entry.title,
                author=player.current_entry.meta['author'].name,
                progress_bar=prog_bar_str,
                progress=prog_str,
                url=player.current_entry.url
            )
        else:
            np_text = "**Song:** [ <{url}> ] \n```{progress} Song: {title}  \n {progress_bar}```".format(
                action=action_text,
                title=player.current_entry.title,
                progress_bar=prog_bar_str,
                progress=prog_str,
                url=player.current_entry.url
            )

        self.server_specific_data[server]['last_np_msg'] = await self.safe_send_message(channel, np_text)
        await self._manual_delete_check(message)
    else:
        return Response(
            'There are no songs queued! Queue something with {}play.'.format(self.config.command_prefix),
            delete_after=30
        )

Ahhh
player.current_entry.url
I thought there had to be something like this but couldn't find it

Thanks!

made mine look like this

from autoplaylist
wntymwagtr6bux4mnkxlva

queued song by me
image

Guys, use '[link]({})'.format(entry.url) instead, otherwise it's ugly.

We now display this in the now playing command, update your bot.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

caseydulong picture caseydulong  ·  6Comments

Dani064g picture Dani064g  ·  6Comments

PRiMENON picture PRiMENON  ·  4Comments

zzulanas picture zzulanas  ·  7Comments

FireFrostLike picture FireFrostLike  ·  4Comments