title: How to get all users in a telegram private channel using telethon?
body: <p>I am trying to get a list of users using telethon in a private telegram channel which I am the admin for, and print it to the console.  I have tried the same code with a channel that is not private, and I'm having the same issues.</p>
  
  <p>What is the username reference I am suppose to use?  I dont understand if that is my telegram username, my channel name, my as if I was to talk in the channel, or what.  Could someone please assist? </p>
  
  <pre><code>  from telethon import TelegramClient
  
     from telethon.tl.functions.contacts import ResolveUsernameRequest
     from telethon.tl.functions.channels import GetAdminLogRequest
     from telethon.tl.functions.channels import GetParticipantsRequest
  
     from telethon.tl.types import ChannelParticipantsRecent
     from telethon.tl.types import InputChannel
     from telethon.tl.types import ChannelAdminLogEventsFilter
     from telethon.tl.types import InputUserSelf
     from telethon.tl.types import InputUser
     # These example values won't work. You must get your own api_id and
     # api_hash from https://my.telegram.org, under API Development.
     api_id = XXXX# Use your own values here. https://my.telegram.org
     api_hash = 'XXX'
     phone_number = 'XXXX'
  
     client = TelegramClient(phone_number, api_id, api_hash)
  
     client.session.report_errors = False
     client.connect()
  
     if not client.is_user_authorized():
      client.send_code_request(phone_number)
      client.sign_in(phone_number, input('Enter the code: '))
  
  channel = client(ResolveUsernameRequest('Jimtest')) # Your channel username --is this the username of my channel? how do I get the right value for this?   It isays username, but seems to reference the channel name?
  
  user = client(ResolveUsernameRequest('@jim')) # what is this value? my username? my "name" in the chat?  the username that outputs when I type as admin in the chat?
  admins = [InputUserSelf(), InputUser(user.users[0].id, user.users[0].access_hash)] # admins
  admins = [] # No need admins for join and leave and invite filters
  
  filter = None # All events
  filter = ChannelAdminLogEventsFilter(True, False, False, False, True, True, True, True, True, True, True, True, True, True)
  cont = 0
  list = [0,100,200,300]
  for num in list:
   result = client(GetParticipantsRequest(InputChannel(channel.chats[0].id, channel.chats[0].access_hash), filter, num, 100, 0))
   for _user in result.users:
    print(_user.id)
  </code></pre>
  
  <p>I'm getting the following errors that look to be problems with the channel or usernames?  What are these values suppose to be?</p>
  
  <pre><code>Traceback (most recent call last):
   File "./maybework.py", line 33, in &lt;module&gt;
      user = client(ResolveUsernameRequest('Jimtest')) # Your channel admin 
  username
    File "/usr/local/lib/python3.6/dist- 
     packages/telethon/telegram_bare_client.py", line 459, in __call__
      result = self._invoke(call_receive, *requests)
    File "/usr/local/lib/python3.6/dist- 
     packages/telethon/telegram_bare_client.py", line 551, in _invoke
      raise next(x.rpc_error for x in requests if x.rpc_error)
  telethon.errors.rpc_error_list.UsernameNotOccupiedError: The username is not in use by anyone else yet
  </code></pre>
  
  <p>Once I fixed that one, or atleast got no error returned, I received this error on the next.  </p>
  
  <pre><code>Traceback (most recent call last):
    File "./maybework.py", line 33, in &lt;module&gt;
       user = client(ResolveUsernameRequest('jimtest')) # Your channel admin 
   username
     File "/usr/local/lib/python3.6/dist- 
  packages/telethon/telegram_bare_client.py", line 459, in __call__
       result = self._invoke(call_receive, *requests)
     File "/usr/local/lib/python3.6/dist- 
   packages/telethon/telegram_bare_client.py", line 551, in _invoke
        raise next(x.rpc_error for x in requests if x.rpc_error)
   telethon.errors.rpc_error_list.UsernameNotOccupiedError: The username is not in use by anyone else yet
  </code></pre>