Ejemplo n.º 1
0
    def build_spotify(self, member, embed=None):
        activity = member.activity

        if not embed:
            embed = utils.EvieeBed()
            embed.set_thumbnail(url=member.avatar_url)
            embed.set_footer(icon_url='https://i.imgur.com/o434xfQ.png',
                             text=f'Listening with Spotify... {member}')

        embed.set_image(url=activity.album_cover_url)
        embed.title = f'{activity.title}'
        embed._colour = activity.color

        artists = ', '.join(activity.artists)
        embed.description = f'by **`{artists}`**.'
        embed.extra = f'{activity.title} {artists}'

        embed.add_field(name='Album', value=activity.album)
        embed.add_field(name='Duration',
                        value=format_delta(delta=activity.duration,
                                           brief=True))
        embed.add_field(
            name='Open in Spotify',
            value=
            f'[Play now!](https://open.spotify.com/track/{activity.track_id})')

        return embed
Ejemplo n.º 2
0
    async def _profile(self, ctx, *, member: discord.Member = None):
        """Show profile information for a member. Includes activity, permissions and other info.

        Parameters
        ------------
        member
            The member to get information from. This can be in the form of an ID, Name, or Mention.

        Examples
        ----------
        <prefix>profile
        <prefix>profile Eviee

            {ctx.prefix}profile
            {ctx.prefix}profile Eviee
        """
        if member is None:
            member = ctx.author

        aembed = None

        activity = member.activity
        embed = utils.EvieeBed(
            title=f'Profile for {member}',
            colour=member.colour,
            description=f'```ini\n'
            f'ID      : {member.id}\n'
            f'CREATED : [{member.created_at.strftime("%d %b, %Y @ %H:%M")}]\n'
            f'JOINED  : [{member.joined_at.strftime("%d %b, %Y @ %H:%M")}]\n'
            f'```')
        embed.set_thumbnail(url=member.avatar_url)
        embed.add_field(name='Display Name', value=member.display_name)
        embed.add_field(
            name='Status',
            value=
            f'{self.statuses.get(str(member.status))} **`{member.status}`**')
        embed.add_field(name='Top Role', value=member.top_role.mention)
        embed.add_field(name='Profile', value=member.mention)

        if activity:
            embed.set_footer(text='Current Activity Info >>')
            embed.add_field(
                name='Activity',
                value=
                f'**`{activity.type.name.capitalize()}` | **{activity.name}')
            aembed = await self.build_activity(member)
            previous = 'Current Activity Info'
        else:
            embed.set_footer(text='Channel Permissions >>')
            previous = 'Member Info'

        perms = await self.get_perms(ctx, member, previous=previous)
        pagey = utils.ProfilePaginator(extras=[embed, aembed, *perms],
                                       member=member,
                                       timeout=120)
        self.bot.loop.create_task(pagey.paginate(ctx))
Ejemplo n.º 3
0
    async def build_activity(self, member, embed=None):
        activity = member.activity

        if activity.type == discord.ActivityType.unknown:
            return None

        if not embed:
            embed = utils.EvieeBed()
            embed.set_thumbnail(url=member.avatar_url)
            embed.set_footer(text='<< Member Info | Channel Permissions >>')

        if isinstance(activity, discord.Spotify):
            embed = self.build_spotify(member, embed)
        elif activity.type == discord.ActivityType.playing:
            embed = self.build_game(member, embed)

        return embed
Ejemplo n.º 4
0
    async def guild_spotify(self, ctx, *, guild: int = None):
        """Show currently playing information from Spotify for your guild.

        Parameters
        ------------
        guild: Optional
            This argument is not required. And defaults to your guild. An ID can be passed.

        Examples
        ----------
        <prefix>spotify guild
        <prefix>spotify guild <guild_id>

            {ctx.prefix}spotify guild
            {ctx.prefix}spotify guild 352006920560967691
        """
        if not guild:
            guild = ctx.guild
        else:
            guild = self.bot.get_guild(guild)

        if not guild:
            return await ctx.send('Could not find a guild with that ID.')

        members = [
            m for m in guild.members if isinstance(m.activity, discord.Spotify)
        ]

        if not members:
            return await ctx.send(
                'No one in your guild is listening to Spotify with Discord.')

        pages = []
        for member in members:
            embed = utils.EvieeBed()
            embed.set_author(name=member.display_name,
                             icon_url=member.avatar_url)
            embed.set_thumbnail(url=member.avatar_url)
            embed.set_footer(icon_url='https://i.imgur.com/o434xfQ.png',
                             text=f'Listening with Spotify... {member}')
            pages.append(self.build_spotify(member, embed=embed))

        pagey = utils.SpotifyPaginator(extras=pages)
        self.bot.loop.create_task(pagey.paginate(ctx))