コード例 #1
0
    async def run_check_all(self, context):
        """
        Print a table of all the user's goals.
        @param context:
        @return:
        """

        now = int(time.time())
        user = User(context.message.author.id, context.guild.id, context)
        embed = discord.Embed(title=lib.get_string('goals', user.get_guild()),
                              color=10038562)

        for type in self.types:

            type_string = lib.get_string('goal:' + type, user.get_guild())
            goal = user.get_goal(type)
            if goal is not None:
                progress = user.get_goal_progress(type)
                left = lib.secs_to_days(goal['reset'] - now)
                text = lib.get_string('goal:yourgoal',
                                      user.get_guild()).format(
                                          type_string, goal['goal']) + "\n"
                text += lib.get_string('goal:status', user.get_guild()).format(
                    progress['percent'], type_string, progress['current'],
                    progress['goal']) + "\n"
                text += lib.get_string('goal:timeleft',
                                       user.get_guild()).format(
                                           left, type_string)
            else:
                text = None

            embed.add_field(name=type_string, value=text, inline=False)

        # Send the message
        await context.send(embed=embed)
コード例 #2
0
    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)
コード例 #3
0
    async def run_check(self, context, type):

        user = User(context.message.author.id, context.guild.id, context)
        type_string = lib.get_string('goal:' + type, user.get_guild())

        user_goal = user.get_goal(type)
        if user_goal:
            progress = user.get_goal_progress(type)
            return await context.send(user.get_mention() + ', ' + lib.get_string('goal:status', user.get_guild()).format(progress['percent'], type_string, progress['current'], progress['goal']))
        else:
            return await context.send(user.get_mention() + ', ' + lib.get_string('goal:nogoal', user.get_guild()).format(type_string, type))
コード例 #4
0
    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)
コード例 #5
0
    async def run_check(self, context):

        user = User(context.message.author.id, context.guild.id, context)

        # Currently only daily goals implemented
        type = 'daily'

        user_goal = user.get_goal(type)
        if user_goal:
            progress = user.get_goal_progress(type)
            return await context.send(
                user.get_mention() + ', ' +
                lib.get_string('goal:status', user.get_guild()).format(
                    progress['str'], progress['percent'], type,
                    progress['current'], progress['goal']))
        else:
            return await context.send(
                user.get_mention() + ', ' +
                lib.get_string('goal:nogoal', user.get_guild()).format(type))