async def profile(self, context):
        """
        Displays your Writer-Bot profile information and statistics.
        """
        user = User(context.message.author.id, context.guild.id, context)
        goals = {'daily': user.get_goal_progress('daily')}
        profile = {
            'lvlxp': user.get_xp_bar(),
            'words': user.get_stat('total_words_written'),
            'words_sprints': user.get_stat('sprints_words_written'),
            'sprints_started': user.get_stat('sprints_started'),
            'sprints_completed': user.get_stat('sprints_completed'),
            'sprints_won': user.get_stat('sprints_won'),
            'challenges_completed': user.get_stat('challenges_completed'),
            'daily_goals_completed': user.get_stat('daily_goals_completed'),
            'goal_progress': str(goals['daily']['percent']) + '%'
        }

        embed = discord.Embed(title=user.get_name(), color=3066993)

        embed.add_field(name=lib.get_string('profile:lvlxp', user.get_guild()),
                        value=profile['lvlxp'],
                        inline=True)
        embed.add_field(name=lib.get_string('profile:words', user.get_guild()),
                        value=profile['words'],
                        inline=True)
        embed.add_field(name=lib.get_string('profile:wordssprints',
                                            user.get_guild()),
                        value=profile['words_sprints'],
                        inline=True)
        embed.add_field(name=lib.get_string('profile:sprintsstarted',
                                            user.get_guild()),
                        value=profile['sprints_started'],
                        inline=True)
        embed.add_field(name=lib.get_string('profile:sprintscompleted',
                                            user.get_guild()),
                        value=profile['sprints_completed'],
                        inline=True)
        embed.add_field(name=lib.get_string('profile:sprintswon',
                                            user.get_guild()),
                        value=profile['sprints_won'],
                        inline=True)
        embed.add_field(name=lib.get_string('profile:challengescompleted',
                                            user.get_guild()),
                        value=profile['challenges_completed'],
                        inline=True)
        embed.add_field(name=lib.get_string('profile:dailygoalscompleted',
                                            user.get_guild()),
                        value=profile['daily_goals_completed'],
                        inline=True)
        embed.add_field(name=lib.get_string('profile:goalprogress',
                                            user.get_guild()),
                        value=profile['goal_progress'],
                        inline=True)

        # Send the message
        await context.send(embed=embed)
    async def profile(self, context):
        """
        Displays your Writer-Bot profile information and statistics.
        """

        if not Guild(context.guild).is_command_enabled('profile'):
            return await context.send(lib.get_string('err:disabled', context.guild.id))

        user = User(context.message.author.id, context.guild.id, context)
        goals = {
            'daily': user.get_goal_progress('daily')
        }
        profile = {
            'lvlxp': user.get_xp_bar(),
            'words': user.get_stat('total_words_written'),
            'words_sprints': user.get_stat('sprints_words_written'),
            'sprints_started': user.get_stat('sprints_started'),
            'sprints_completed': user.get_stat('sprints_completed'),
            'sprints_won': user.get_stat('sprints_won'),
            'challenges_completed': user.get_stat('challenges_completed'),
            'daily_goals_completed': user.get_stat('daily_goals_completed'),
            'weekly_goals_completed': user.get_stat('weekly_goals_completed'),
            'monthly_goals_completed': user.get_stat('monthly_goals_completed'),
            'yearly_goals_completed': user.get_stat('yearly_goals_completed'),
        }

        embed = discord.Embed(title=user.get_name(), color=3066993)

        embed.add_field(name=lib.get_string('profile:lvlxp', user.get_guild()), value=profile['lvlxp'], inline=True)
        embed.add_field(name=lib.get_string('profile:words', user.get_guild()), value=profile['words'], inline=True)
        embed.add_field(name=lib.get_string('profile:wordssprints', user.get_guild()), value=profile['words_sprints'], inline=True)
        embed.add_field(name=lib.get_string('profile:sprintsstarted', user.get_guild()), value=profile['sprints_started'], inline=True)
        embed.add_field(name=lib.get_string('profile:sprintscompleted', user.get_guild()), value=profile['sprints_completed'], inline=True)
        embed.add_field(name=lib.get_string('profile:sprintswon', user.get_guild()), value=profile['sprints_won'], inline=True)
        embed.add_field(name=lib.get_string('profile:challengescompleted', user.get_guild()), value=profile['challenges_completed'], inline=True)
        embed.add_field(name=lib.get_string('profile:dailygoalscompleted', user.get_guild()), value=profile['daily_goals_completed'], inline=True)
        embed.add_field(name=lib.get_string('profile:weeklygoalscompleted', user.get_guild()), value=profile['weekly_goals_completed'], inline=True)
        embed.add_field(name=lib.get_string('profile:monthlygoalscompleted', user.get_guild()), value=profile['monthly_goals_completed'], inline=True)
        embed.add_field(name=lib.get_string('profile:yearlygoalscompleted', user.get_guild()), value=profile['yearly_goals_completed'], inline=True)


        # Send the message
        await context.send(embed=embed)
Esempio n. 3
0
    def get_leaderboard(self, limit=None):
        """
        Build the embedded leaderboard to display
        :return:
        """

        config = lib.get('./settings.json')
        users = self.get_users()

        # Build the embedded leaderboard message
        title = self.get_title() + ' ' + lib.get_string(
            'event:leaderboard', self.get_guild())
        description = lib.get_string('event:leaderboard:desc',
                                     self.get_guild()).format(
                                         limit, self.get_title())
        footer = lib.get_string('event:leaderboard:footer',
                                self.get_guild()).format(limit)

        # If there is no limit, don't show the footer
        if limit is None:
            footer = None

        # If the event is finished, don't show the footer and adjust the description to take out 'so far'
        if self.is_ended():
            description = lib.get_string('event:leaderboard:desc:ended',
                                         self.get_guild()).format(
                                             self.get_title())
            footer = None

        image = self.get_image()
        if not image or len(image) == 0:
            image = config.avatar

        embed = discord.Embed(title=title,
                              color=self.get_colour(),
                              description=description)
        embed.set_thumbnail(url=image)
        if footer:
            embed.set_footer(text=footer, icon_url=config.avatar)

        # Add users
        position = 1

        for user in users:

            # Get the user and pass in the bot, so we can get their guild nickname
            user_object = User(user['user'],
                               self.get_guild(),
                               context=self.__context,
                               bot=self.__bot)

            # Easiest way to check if the user is still a member of the guild, is to see if we can get their nickname
            if user_object.is_guild_member():

                # Build the name and words variables to display in the list
                name = str(position) + '. ' + user_object.get_name()
                words = str(user['words'])

                # Embed this user result as a field
                embed.add_field(name=name, value=words, inline=False)

                # Increment position
                position += 1

        return embed