title: Can I make a bot to scrape a Discord server once it''s logged in?
body: <p>Below is the beginning of a script to scrape a discord server with a bot.</p>
  <p>How do I edit it to scrape from every channel in the server once I've logged in with the bot? (Perhaps by editing on_ready() instead of on_message()?)</p>
  <p>Essentially, I want to scrape a channel without entering &quot;_scan&quot; into it. I would hard code the number of messages to scrape.</p>
  <p>I give full credit for this to <a href="https://levelup.gitconnected.com/how-to-gather-message-data-using-a-discord-bot-from-scratch-with-python-2fe239da3bcd" rel="nofollow noreferrer">https://levelup.gitconnected.com/how-to-gather-message-data-using-a-discord-bot-from-scratch-with-python-2fe239da3bcd</a>, and more thoroughly, <a href="https://github.com/ThiagoFPMR/Scraper-Bot/blob/main/bot.py" rel="nofollow noreferrer">https://github.com/ThiagoFPMR/Scraper-Bot/blob/main/bot.py</a>.</p>
  <pre><code>import os
  import discord
  import logging
  import pandas as pd
  
  logging.basicConfig(level=logging.INFO)
  
  client = discord.Client()
  guild = discord.Guild
  
  @client.event
  async def on_ready():
      print('We have logged in as {0.user}'.format(client))
      await client.change_presence(activity=discord.Game('_scan help'))
  
  @client.event
  async def on_message(message):
      if message.author == client.user:
          return
      elif message.content.startswith('_'):
  
          cmd = message.content.split()[0].replace(&quot;_&quot;,&quot;&quot;)
          if len(message.content.split()) &gt; 1:
              parameters = message.content.split()[1:]
  
          # Bot Commands
  
          if cmd == 'scan':
  
              data = pd.DataFrame(columns=['content', 'time', 'author'])
  
              # Acquiring the channel via the bot command
              if len(message.channel_mentions) &gt; 0:
                  channel = message.channel_mentions[0]
              else:
                  channel = message.channel
  
              ...
  </code></pre>