title: How to fetch messages using discord.py
body: <p>I have created a piece of code that used to be a snipe function to a fetch function I assume snipe and fetch are basically the opposite of each other and my theory seems to be true! However that is not the case or why I am creating this question, I am having issues with my messages not being fetched after I run my <code>!fetch</code> command, there is no outcome which is supposed to be a embed that displays the content/message.</p>
  <p><strong>Concern/question</strong></p>
  <p>My code does not send an embed after the <code>!fetch</code> command is ran, there is no error listed within the console/terminal. However, when a message is sent within the channel the embed information is logged/shown within the console (Discord name, tag, id, guild id, guild name etc)! <strong>I want to fetch messages from a channel and print the messages when the command is ran.</strong></p>
  <p><strong>Code</strong></p>
  <pre><code>import discord
  from discord.ext import commands
  from tokens import token, CHANNEL_ID
  
  client = commands.Bot(command_prefix='!')
  client.sniped_message = None
  
  @client.event
  async def on_ready():
      print(&quot;Your bot is ready.&quot;)
  
  @client.event
  async def on_message(message):
      # Make sure it's in the watched channel, and not one of the bot's own
      # messages.
      if message.channel.id == CHANNEL_ID and message.author != client.user:
          print(f'Fetched message: {message}')
          client.sniped_message = message
  
  @client.command()
  async def fetch(ctx):
      # Only respond to the command in the watched channel.
      if ctx.channel.id != CHANNEL_ID:
          return
  
      if client.sniped_message is None:
          await ctx.channel.send(&quot;Couldn't find a message to fetch!&quot;)
          return
  
      message = client.sniped_message
  
      embed = discord.Embed(
          description=message.content,
          color=discord.Color.purple(),
          timestamp=message.created_at
      )
      embed.set_author(
          name=f&quot;{message.author.name}#{message.author.discriminator}&quot;,
          icon_url=message.author.avatar_url
      )
      embed.set_footer(text=f&quot;Message sent in: #{message.channel.name}&quot;)
  
      await ctx.channel.send(embed=embed)
  
  client.run(token)
  </code></pre>
  <p><em>I'm not really sure if the <code>sniped</code> messages have a impact on the code.</em>
  Also, this code was shared from my friend, who received helped with his snipe function.* Thanks!</p>