async def xp(self, context, who='me'): """ Checks your Experience Points and Level. Use the 'top' flag to see the top 10 on this server. Examples: !xp - Shows your level/xp !xp top - Shows the top 10 users on this server """ guild_id = context.guild.id user_id = context.message.author.id if who == 'top': guild = Guild(context.guild) users = guild.get_top_xp() output = ':trophy: **' + lib.get_string( 'xp:leaderboard', guild_id) + '** :trophy: \n\n' for key in range(len(users)): user = users[key] output += str(key + 1) + '. ' + user.get_name( ) + ' - ' + user.get_xp_bar() + '\n' else: user = User(user_id, guild_id) xp = user.get_xp() # Either display a message saying they have no XP, or display the XP bar for the user if xp is None: output = context.message.author.mention + ', ' + lib.get_string( 'xp:noxp', guild_id) else: output = context.message.author.mention + ', ' + lib.get_string( 'youare', guild_id) + ' ' + user.get_xp_bar() await context.send(output)
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)
async def xp(self, context, who='me'): """ Checks your Experience Points and Level. Use the 'top' flag to see the top 10 on this server. Examples: !xp - Shows your level/xp !xp top - Shows the top 10 users on this server """ guild_id = context.guild.id user_id = context.message.author.id if who == 'top': title = context.guild.name + ' - ' + lib.get_string( 'xp:leaderboard', guild_id) embed = discord.Embed(title=title, color=discord.Color.red(), description=None) embed.add_field( name=lib.get_string('xp:leaderboard', guild_id), value= 'Leaderboard temporarily disabled until a fix can be implemented', inline=False) return await context.send(embed=embed) else: user = User(user_id, guild_id) xp = user.get_xp() # Either display a message saying they have no XP, or display the XP bar for the user if xp is None: output = context.message.author.mention + ', ' + lib.get_string( 'xp:noxp', guild_id) else: output = context.message.author.mention + ', ' + lib.get_string( 'youare', guild_id) + ' ' + user.get_xp_bar() await context.send(output)