title: How to make a bot that listens for messages and sends them to another server?
body: <p>I'm trying to make a bot that listens for messages in a channel and sends them to my private server. I don't fully understand coding stuff so I relied on some online sources.</p>
  
  <p>I already have done a bot that gets the new messages in a channel then brings them to a private channel. I cannot find the GitHub where the code was located since I moved to another OS. Now that's out of the way, I need the bot to send the logs to my private server in case some of my staff accidentally deletes one of the logs/multiple log. Then I came across this similar question: <a href="https://stackoverflow.com/questions/51112006/how-to-send-a-message-to-a-different-server-discord-bot">How to send a message to a different server | Discord Bot</a> , but I realized this was JavaScript not python. Nonetheless, I moved to that JavaScript and tried it.</p>
  
  <p>Here's the Python bot that I got from a GitHub. It creates an embed of the message it listened and sends them to the channel it specified (#message-log). It also includes the the author's avatar and name</p>
  
  <pre><code>@client.event
  async def on_message(message):
      guild = message.guild
      log_channel = discord.utils.get(guild.channels, name="message-log")
      if log_channel is None:
          await client.process_commands(message)
          return
      if not message.author.bot:
          embed=discord.Embed(
              color=0xffd700,
              timestamp=datetime.datetime.utcnow(),
              description="in {}:\n{}".format(message.channel.mention, message.content)
          )
          embed.set_author(name=message.author, icon_url=message.author.avatar_url)
          embed.set_footer(text=message.author.id)
          if len(message.attachments) &gt; 0:
              embed.set_image(url = message.attachments[0].url)
          await log_channel.send(embed=embed)
          await client.process_commands(message)
  </code></pre>
  
  <p>Then here's the JavaScript code (this is not my focus, but I decided to include it for emergency). It gets the listened server guild ID and channel. I don't know if it's really capable of sending it to my private server since there are errors.</p>
  
  <pre><code>client.guilds.get(&lt;guild id&gt;).channels.get(&lt;channel id&gt;).send(&lt;message&gt;)
  </code></pre>
  
  <p>I also didn't include IDs for privacy reasons.</p>
  
  <p>I anticipated that JavaScript would run like it would normally would, but it returned an error below. </p>
  
  <pre><code>TypeError: Cannot read property 'channels' of undefined
      at Object.&lt;anonymous&gt; (C:\Users\SomethingCube\Desktop\ListenBot\ListenBot.js:12:40)
      at Module._compile (internal/modules/cjs/loader.js:776:30)
      at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
      at Module.load (internal/modules/cjs/loader.js:653:32)
      at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
      at Function.Module._load (internal/modules/cjs/loader.js:585:3)
      at Function.Module.runMain (internal/modules/cjs/loader.js:829:12)
      at startup (internal/bootstrap/node.js:283:19)
      at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
  </code></pre>
  
  <p>Probably because the code I got (JavaScript) was made in 2018 and many things changed before I posted this, or I'm doing something wrong (I'm guessing that I placed the wrong prefix and suffix (I don't know what's that called) of the IDs, ("------------------")).</p>
  
  <p>Again, JavaScript is not my focus here but Python. I'm looking for a code (for Python) that sends the messages to my private server.</p>