title: Making embeds of more than one page using discord.py
body: <p>I'm currently trying to make a bot using discord.py. One of the functions I want it to have is to show the users with X role. I've managed to create said function, and make the bot send the results with a nice embed. However, now I want to improve it and make it more similar to Nadeko's inrole function (i.e. only one embed and the user can react to it to change the page).</p>
  <pre><code>@client.command(name = &quot;inrole&quot;, brief = &quot;Users with a certain role&quot;,
              description= &quot;I'll give you a list with all the users with a certain role.&quot;, pass_context=True)
  async def inrole(ctx, *args):
      server = ctx.message.guild
      role_name = (' '.join(args))
      role_id = server.roles[0]
      for role in server.roles:
          if role_name.lower() == role.name.lower():
              role_id = role
              break
      else:
          await ctx.send(f&quot;Oh noes! That role doesn't exist!&quot;)
          return
      n = 0
      members = []
  
      for member in server.members:
          if role_id in member.roles:
              n += 1
              name = str(n) + &quot;. &quot; + member.name + &quot; #&quot; + member.discriminator + &quot;\n&quot;
              members.append(name)
      composite_members = [members[x:x + 20] for x in range(0, len(members), 20)]
  
      for elements in composite_members:
          string = &quot;&quot;
          for element in elements:
              string = string + element
          embedVar = discord.Embed(title=f&quot;List of users with {role} - {n}&quot;, colour=discord.Colour.blue())
          embedVar.add_field(name = &quot;Members&quot;, value = string)
          await ctx.send(embed=embedVar)
  </code></pre>
  <p>I've read the documentation, but I'm still quite lost in how to make it like Nadeko's. Right now, if there are 200 users with that role, then it will print 10 embeds, which can be rather annoying.
  Thanks in advance!</p>
  <p>EDIT:
  I've improved the code a bit, but now I have a different problem.</p>
  <pre><code>def predicate(message, l, r):
      def check(reaction, user):
  
          if reaction.message.id != message.id or user == client.user:
              return False
          if l and reaction.emoji == &quot;⏪&quot;:
              return True
          if r and reaction.emoji == &quot;⏩&quot;:
              return True
          return False
  
      return check
  
  #inrole function. To see all members with that role
  @client.command(name = &quot;inrole&quot;, brief = &quot;Users with a certain role&quot;,
                  description= &quot;I'll give you a list with all the users with a certain role.&quot;, pass_context=True)
  async def inrole(ctx, *role):
      server = ctx.message.guild
      role_name = (' '.join(role))
      role_id = server.roles[0]
      for role in server.roles:
          if role_name.lower() == role.name.lower():
              role_id = role
              break
      else:
          await ctx.send(f&quot;Oh noes! That role doesn't exist!&quot;)
          return
      n = 0
      members = []
      for member in server.members:
          if role_id in member.roles:
              n += 1
              name = str(n) + &quot;. &quot; + member.name + &quot; #&quot; + member.discriminator + &quot;\n&quot;
              members.append(name)
      composite_members = [members[x:x + 20] for x in range(0, len(members), 20)]
      pages = []
      for elements in composite_members:
          string = &quot;&quot;
          for element in elements:
              string = string + element
          embedVar = discord.Embed(title=f&quot;List of users with {role} - {n}&quot;, colour=discord.Colour.blue())
          embedVar.add_field(name = &quot;Members&quot;, value = string)
          pages.append(embedVar)
  
      page = 0
      left = &quot;⏪&quot;
      right = &quot;⏩&quot;
      while True:
          msg = await ctx.send(embed = pages[(page)])
          l = page != 0
          r = page != len(pages) - 1
          if l:
              await msg.add_reaction(left)
  
          if r:
              await msg.add_reaction(right)
          # bot.wait_for_reaction
          react = await client.wait_for('reaction_add', check=predicate(msg, l, r))
          
          if react[0] == left:
              page -= 1
          elif react[0] == right:
              page += 1
  
          await msg.delete()
  </code></pre>
  <p>In the last if/elif statement, it doesn't work. There isn't an error, but although <code>react[0]</code> is the same emoji as <code>right</code> or <code>left</code> (respectively), <code>page</code> never changes, and thus the embed doesn't change either. I changed the elif for an else, and it that case it does work, but it can only go forward.</p>