Example #1
0
    def embed(self):
        embed = discord.Embed()
        embed.title = f'Enqueued {self.entry.title}'
        embed.url = self.entry.url
        embed.add_field(name='Duration', value=time.human_time(self.entry.duration))
        if self.progress:
            embed.title = f'Currently playing {self.entry.title}'
            embed.add_field(name='Progress', value=time.human_time(self.progress))
            embed.add_field(name='Requester', value=self.requester, inline=False)

        return embed
Example #2
0
    async def play(self, ctx, *, query: str):
        """Plays a song.

        If there is a song currently in the queue, then it is
        queued until the next song is done playing.

        This command automatically searches as well from YouTube.
        The list of supported sites can be found here:
        https://rg3.github.io/youtube-dl/supportedsites.html
        """
        if ctx.author.voice is None:
            return await ctx.send('You need to be in a voice channel.')
        vc = ctx.guild.voice_client
        if vc is None:
            vc = await ctx.invoke(self.summon)
            if vc is None:
                return

        source = YoutubeSource(ctx.message, query)
        embed = source.embed()
        queue = self.get_queue(ctx.guild)
        if not vc.is_playing() and not vc.is_paused():
            time_until = 'Up next!'
        else:
            songs = queue.songs._queue
            length = sum(song.length for song in songs) + vc.source.remaining
            time_until = time.human_time(length)
        embed.add_field(name='Time until playing', value=time_until)
        message = await ctx.send(embed=embed)
        await queue.songs.put(source)
        await asyncio.sleep(15)
        await message.delete()
Example #3
0
    def embed(self):
        embed = discord.Embed(color=0xffffff)
        embed.title = 'Enqueued {}'.format(self.entry.title)
        embed.url = self.entry.url
        embed.add_field(name='Duration',
                        value=time.human_time(self.entry.duration))
        if self.progress:
            embed.title = 'Currently playing {}'.format(self.entry.title)
            embed.add_field(name='Progress',
                            value=time.human_time(self.progress))
            embed.add_field(name='Requester',
                            value=self.requester,
                            inline=False)
            embed.add_field(name='Skips',
                            value='{}/{}'.format(len(self.skip_votes),
                                                 self.required_skips))

        return embed
Example #4
0
    async def play(self, ctx, *, query: str):
        if ctx.author.voice is None:
            embed = discord.Embed(description = f"**{ctx.author.name}**, you need to be in a voice channel.", color = embed_color_attention)
            return await ctx.send(embed = embed, delete_after = 15)
        vc = ctx.guild.voice_client
        if vc is None:
            vc = await ctx.invoke(self.summon)
            if vc is None:
                return

        source = YoutubeSource(ctx.message, query)
        embed = source.embed()
        queue = self.get_queue(ctx.guild)
        if not vc.is_playing() and not vc.is_paused():
            time_until = ' Up next!'
        else:
            songs = queue.songs._queue
            length = sum(song.length for song in songs) + vc.source.remaining
            time_until = time.human_time(length)
        embed.add_field(name='Time until playing ', value=time_until)
        await ctx.send(embed=embed, delete_after = 15)
        await queue.songs.put(source)
Example #5
0
    async def wheresmysong(self, ctx):
        """Shows how long until your next song will play."""
        vc = ctx.voice_client
        if vc is None:
            return await ctx.send('Not in a voice channel.')

        if not vc.is_playing() and not vc.is_paused():
            return await ctx.send('Not playing any music right now...')
        songs = self.get_queue(ctx.guild).songs._queue
        if not songs:
            return await ctx.send('Nothing currently in the queue.')
        requesters = set(song.requester for song in songs)
        if ctx.author not in requesters:
            return await ctx.send('You are not in the queue!')
        remaining = vc.source.remaining
        for song in songs:
            if song.requester == ctx.author:
                break
            remaining += song.length

        message = await ctx.send('{} until your next song!'.format(
            time.human_time(remaining)))
        await asyncio.sleep(15)
        await message.delete()