async def gimme_common(username, points, types): query = Query() unsolved = query.get_unsolved_problems(username, types, points[0], points[1]) if len(unsolved) == 0: return None, None problem = random.choice(unsolved) # Sometimes the problem might not contain the memory info # so we need to call the api problem = await query.get_problem(problem.code) points = str(problem.points) if problem.partial: points += 'p' memory = problem.memory_limit if memory >= 1024 * 1024: memory = '%dG' % (memory // 1024 // 1024) elif memory >= 1024: memory = '%dM' % (memory // 1024) else: memory = '%dK' % (memory) embed = discord.Embed( title=problem.name, url='https://dmoj.ca/problem/%s' % problem.code, description='Points: %s\nProblem Types: %s' % (points, ', '.join(problem.types)), color=0xfcdb05, ) embed.set_thumbnail(url=await query.get_pfp(username)) embed.add_field(name='Group', value=problem.group, inline=True) embed.add_field( name='Time', value='%ss' % problem.time_limit, inline=True ) embed.add_field(name='Memory', value=memory, inline=True) return embed, problem
async def gimme_common(username, points, types): query = Query() unsolved = query.get_unsolved_problems(username, types, points[0], points[1]) if len(unsolved) == 0: return None, None problem = random.choice(unsolved) # Sometimes the problem might not contain the memory info # so we need to call the api problem = await query.get_problem(problem.code) points = str(problem.points) if problem.partial: points += "p" memory = problem.memory_limit if memory >= 1024 * 1024: memory = "%dG" % (memory // 1024 // 1024) elif memory >= 1024: memory = "%dM" % (memory // 1024) else: memory = "%dK" % (memory) embed = hikari.Embed( title=problem.name, url="https://dmoj.ca/problem/%s" % problem.code, description="Points: %s\nProblem Types: %s" % (points, ", ".join(problem.types)), color=0xFCDB05, ) embed.set_thumbnail(await query.get_pfp(username)) embed.add_field(name="Group", value=problem.group, inline=True) embed.add_field(name="Time", value="%ss" % problem.time_limit, inline=True) embed.add_field(name="Memory", value=memory, inline=True) return embed, problem