title: Discord Client Bot not responding the right way? Discord.py
body: <p><strong>ANSWER:</strong></p>
  <p>So I did something else from the Question down bellow, I actually did not use the <code>.JSON</code> File and tried this:</p>
  <p><strong>Prefixes.py</strong> (File in Cogs):</p>
  <pre><code>    @commands.Cog.listener()
      async def on_message(self, message):
  
          mention = f'&lt;@!{self.client.user.id}&gt;'
          if mention in message.content:
              prefix = await self.client.get_prefix(message)
              try:
                  x = &quot;&quot;
                  pfp = self.client.user.avatar_url
                  prefix = discord.Embed(title=x, description=f&quot;My prefix for **{message.guild.name}** is `{prefix}`. If you want to find out more information about me type `{prefix}help`.&quot;, color = 0x456383)
                  prefix.set_footer(text=f&quot;ChizLanks&quot;, icon_url=pfp)
                  await message.channel.send(embed = prefix)
              except discord.Forbidden:
                  return await message.channel.send(f&quot;My prefix for **{message.guild.name}** is `{prefix}`. If you want to find out more information about me type `{prefix}help`&quot;)
  </code></pre>
  <p>What I did is that, I added the <code>prefix = await self.client.get_prefix(message)</code>. This will get the prefix from the <code>.JSON</code> File or if the <code>.JSON</code> File is empty it will use the Default Prefix <code>/</code> which can be found in the <code>Main.py</code> File. This worked fine for me and it should be working fine for you too. What I have in my Main file can be found down here:</p>
  <p><strong>Main.py</strong>:</p>
  <pre><code>def get_prefix(client, message):
      with open('prefixes.json', 'r') as file:
          prefixes = json.load(file)
  
      if str(message.guild.id) in prefixes:
          return prefixes[str(message.guild.id)]
  
      else:
          return &quot;/&quot;
  
  client = commands.Bot(command_prefix = get_prefix)
  
  </code></pre>
  <p>===========================================================================</p>
  <p><strong>QUESTION:</strong></p>
  <p>So I was making an <code>on_message</code> Event, so whenever someone mentioned the Client's ID, it would respond with a message which would have the Server Prefix on it. (I'm using a <code>per-server-prefix</code> system.) So I tried this:</p>
  <pre><code>    @commands.Cog.listener()
      async def on_message(self, message):
  
  
          def botprefix(self, message):
              with open('prefixes.json', 'r') as file:
                  prefixes = json.load(file)
  
              if str(message.guild.id) in prefixes:
                  return prefixes[str(message.guild.id)]
  
              else:
                  return &quot;/&quot;
  
          mention = f'&lt;@!{self.client.user.id}&gt;'
          if mention in message.content:
              try:
                  x = &quot;&quot;
                  pfp = self.client.user.avatar_url
                  prefix = discord.Embed(title=x, description=f&quot;My prefix for **{message.guild.name}** is `{botprefix}`. If you want to find out more information about me type `{botprefix}help`.&quot;, color = 0x456383)
                  prefix.set_footer(text=f&quot;ChizLanks&quot;, icon_url=pfp)
                  await message.channel.send(embed = prefix)
              except discord.Forbidden:
                  return await message.channel.send(f&quot;My prefix for **{message.guild.name}** is `{botprefix}`. If you want to find out more information about me type `{botprefix}help`&quot;)
  
  </code></pre>
  <p>But it seems it was not working correctly, and whenever I mentioned the bot this would show up<a href="https://i.stack.imgur.com/7CxJw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7CxJw.png" alt="enter image description here" /></a></p>
  <p>Could anyone explain why this is not working and how I can fix it?</p>