original_docstring: Gets a random question from the Technician, General, and/or Extra question pools.
docstring: Gets a random question from the Technician, General, and/or Extra question pools.
docstring_tokens: Gets a random question from the Technician General and / or Extra question pools .
code: async def rq(ctx, level: str = None):
      '''Gets a random question from the Technician, General, and/or Extra question pools.'''
      with ctx.typing():
          selected_pool = None
          try:
              level = level.lower()
          except AttributeError:  # no level given (it's None)
              pass
  
          if level in ['t', 'technician', 'tech']:
              selected_pool = tech_pool
  
          if level in ['g', 'gen', 'general']:
              selected_pool = gen_pool
  
          if level in ['e', 'extra']:
              selected_pool = extra_pool
  
          if (level is None) or (level == 'all'):  # no pool given or user wants all, so pick a random pool and use that
              selected_pool = random.choice([tech_pool, gen_pool, extra_pool])
          if (level is not None) and (selected_pool is None):  # unrecognized pool given by user
              await ctx.send('The question pool you gave was unrecognized. ' +
                            'There are many ways to call up certain question pools - try ?rq t, g, or e. ' +
                            '(Note that only the US question pools are available).')
              return
  
          question = random.choice(selected_pool)
          embed = discord.Embed(title=question['number'], colour=green)
          embed = embed.add_field(name='Question:', value=question['text'], inline=False)
          embed = embed.add_field(name='Answers:', value=
                                  '**A:** ' + question['answers'][0] +
                                  '\n**B:** ' + question['answers'][1] +
                                  '\n**C:** ' + question['answers'][2] +
                                  '\n**D:** ' + question['answers'][3], inline=False)
          embed = embed.add_field(name='Answer:', value='Type _?rqa_ for answer', inline=False)
          global lastq
          lastq[ctx.message.channel.id] = (question['number'], question['answer'])
      await ctx.send(embed=embed)
code_tokens: async def rq ( ctx , level : str = None ) : with ctx . typing ( ) : selected_pool = None try : level = level . lower ( ) except AttributeError : pass if level in [ 't' , 'technician' , 'tech' ] : selected_pool = tech_pool if level in [ 'g' , 'gen' , 'general' ] : selected_pool = gen_pool if level in [ 'e' , 'extra' ] : selected_pool = extra_pool if ( level is None ) or ( level == 'all' ) : selected_pool = random . choice ( [ tech_pool , gen_pool , extra_pool ] ) if ( level is not None ) and ( selected_pool is None ) : await ctx . send ( 'The question pool you gave was unrecognized. ' + 'There are many ways to call up certain question pools - try ?rq t, g, or e. ' + '(Note that only the US question pools are available).' ) return question = random . choice ( selected_pool ) embed = discord . Embed ( title = question [ 'number' ] , colour = green ) embed = embed . add_field ( name = 'Question:' , value = question [ 'text' ] , inline = False ) embed = embed . add_field ( name = 'Answers:' , value = '**A:** ' + question [ 'answers' ] [ 0 ] + '\n**B:** ' + question [ 'answers' ] [ 1 ] + '\n**C:** ' + question [ 'answers' ] [ 2 ] + '\n**D:** ' + question [ 'answers' ] [ 3 ] , inline = False ) embed = embed . add_field ( name = 'Answer:' , value = 'Type _?rqa_ for answer' , inline = False ) global lastq lastq [ ctx . message . channel . id ] = ( question [ 'number' ] , question [ 'answer' ] ) await ctx . send ( embed = embed )
short_docstring: Gets a random question from the Technician, General, and/or Extra question pools.
short_docstring_tokens: Gets a random question from the Technician General and / or Extra question pools .
comment: '''Gets a random question from the Technician, General, and/or Extra question pools.'''$SEP$# no level given (it's None)$SEP$# no pool given or user wants all, so pick a random pool and use that$SEP$# unrecognized pool given by user