title: AttributeError: 'NoneType' object has no attribute 'get_role' 'send' or 'members'
body: <p>I'm getting the same error multiple times for a program and I can't find what the issue is; I keep getting the same error</p>
  <pre><code>_ClientEventTask exception was never retrieved
  future: &lt;ClientEventTask state=finished event=on_ready coro=&lt;bound method Mod.on_ready of &lt;lib.cogs.mod.Mod object at 0x000001B219E2BBE0&gt;&gt; exception=AttributeError(&quot;'NoneType' object has no attribute 'send'&quot;)&gt;
  Traceback (most recent call last):
    File &quot;C:\Users\jacob\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py&quot;, line 343, in _run_event
      await coro(*args, **kwargs)
    File &quot;c:\Projects\BobbyBot\lib\cogs\mod.py&quot;, line 278, in on_ready
      self.mute_role = self.bot.guild.get_role(653941858128494600)
  AttributeError: 'NoneType' object has no attribute 'get_role'
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File &quot;C:\Users\jacob\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py&quot;, line 348, in _run_event
      await self.on_error(event_name, *args, **kwargs)
    File &quot;c:\Projects\BobbyBot\lib\bot\__init__.py&quot;, line 125, in on_error
      await self.stdout.send(&quot;An error occured.&quot;)
  AttributeError: 'NoneType' object has no attribute 'send'
  _ClientEventTask exception was never retrieved
  future: &lt;ClientEventTask state=finished event=on_ready coro=&lt;bound method Reactions.on_ready of &lt;lib.cogs.reactions.Reactions object at 0x000001B219ECC7C0&gt;&gt; exception=AttributeError(&quot;'NoneType' object has no attribute 'send'&quot;)&gt;
  Traceback (most recent call last):
    File &quot;C:\Users\jacob\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py&quot;, line 343, in _run_event
      await coro(*args, **kwargs)
    File &quot;c:\Projects\BobbyBot\lib\cogs\reactions.py&quot;, line 27, in on_ready
      &quot;\u2764\ufe0f&quot;: self.bot.guild.get_role(653940117680947232), # Red
  AttributeError: 'NoneType' object has no attribute 'get_role'
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File &quot;C:\Users\jacob\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\discord\client.py&quot;, line 348, in _run_event
      await self.on_error(event_name, *args, **kwargs)
    File &quot;c:\Projects\BobbyBot\lib\bot\__init__.py&quot;, line 125, in on_error
      await self.stdout.send(&quot;An error occured.&quot;)
  AttributeError: 'NoneType' object has no attribute 'send'
  </code></pre>
  <p>Here is the main document of which everything is based:</p>
  <pre><code>from asyncio import sleep
  from datetime import datetime
  from glob import glob
  
  from apscheduler.schedulers.asyncio import AsyncIOScheduler
  from apscheduler.triggers.cron import CronTrigger
  from discord import Embed, File, DMChannel, Intents
  from discord.errors import HTTPException, Forbidden
  from discord.ext.commands import Bot as BotBase
  from discord.ext.commands import Context
  from discord.ext.commands import (CommandNotFound, BadArgument, MissingRequiredArgument,
                                    CommandOnCooldown)
  from discord.ext.commands import when_mentioned_or, command, has_permissions
  
  from ..db import db
  
  OWNER_IDS = [213438742315139073]
  COGS = [path.split(&quot;\\&quot;)[-1][:-3] for path in glob(&quot;./lib/cogs/*.py&quot;)]
  IGNORE_EXCEPTIONS = (CommandNotFound, BadArgument)
  
  
  def get_prefix(bot, message):
      prefix = db.field(
          &quot;SELECT Prefix FROM guilds WHERE GuildID = ?&quot;, message.guild.id)
      return when_mentioned_or(prefix)(bot, message)
  
  
  class Ready(object):
      def __init__(self):
          for cog in COGS:
              setattr(self, cog, False)
  
      def ready_up(self, cog):
          setattr(self, cog, True)
          print(f&quot; {cog} cog ready&quot;)
  
      def all_ready(self):
          return all([getattr(self, cog) for cog in COGS])
  
  
  class Bot(BotBase):
      def __init__(self):
          self.ready = False
          self.cogs_ready = Ready()
  
          self.guild = None
          self.scheduler = AsyncIOScheduler()
  
          try:
              with open(&quot;./data/banlist.txt&quot;, &quot;r&quot;, encoding=&quot;utf-8&quot;) as f:
                  self.banlist = [int(line.strip()) for line in f.readlines()]
          except FileNotFoundError:
              self.banlist = []
  
          db.autosave(self.scheduler)
          super().__init__(
              command_prefix=get_prefix, 
              owner_ids=OWNER_IDS,
              intents=Intents.all()
              )
  
      def setup(self):
          for cog in COGS:
              self.load_extension(f&quot;lib.cogs.{cog}&quot;)
              print(f&quot; {cog} cog loaded&quot;)
  
          print(&quot;setup complete&quot;)
  
      def update_db(self):
          db.multiexec(&quot;INSERT OR IGNORE INTO guilds (GuildID) VALUES (?)&quot;,
                       ((guild.id,) for guild in self.guilds))
  
          db.multiexec(&quot;INSERT OR IGNORE INTO exp (UserID) VALUES (?)&quot;,
                       ((member.id,) for member in self.guild.members if not member.bot))
  
          to_remove = []
          stored_members = db.column(&quot;SELECT UserID FROM exp&quot;)
          for id_ in stored_members:
              if not self.guild.get_member(id_):
                  to_remove.append(id_)
  
          db.multiexec(&quot;DELETE FROM exp WHERE UserID = ?&quot;,
                       ((id_,) for id_ in to_remove))
  
          db.commit()
  
      def run(self, version):
          self.VERSION = version
  
          print(&quot;running setup...&quot;)
          self.setup()
  
          with open(&quot;./lib/bot/token.0&quot;, &quot;r&quot;, encoding=&quot;utf-8&quot;) as tf:
              self.TOKEN = tf.read()
  
          print(&quot;running bot...&quot;)
          super().run(self.TOKEN, reconnect=True)
  
      async def process_commands(self, message):
          ctx = await self.get_context(message, cls=Context)
  
          if ctx.command is not None and ctx.guild is not None:
              if message.author.id in self.banlist:
                  await ctx.send(&quot;You are banned from using commands.&quot;)
  
              elif not self.ready:
                  await ctx.send(&quot;I'm not ready to receive commands. Please wait a few seconds.&quot;)
  
              else:
                  await self.invoke(ctx)
  
      async def rules_reminder(self):
          await self.stdout.send(&quot;Remember to adhere to the rules!&quot;)
  
      async def on_connect(self):
          print(&quot; bot connected&quot;)
  
      async def on_disconnect(self):
          print(&quot;bot disconnected&quot;)
  
      async def on_error(self, err, *args, **kwargs):
          if err == &quot;on_command_error&quot;:
              await args[0].send(&quot;Something went wrong.&quot;)
  
          await self.stdout.send(&quot;An error occured.&quot;)
          raise
  
      async def on_command_error(self, ctx, exc):
          if any([isinstance(exc, error) for error in IGNORE_EXCEPTIONS]):
              pass
  
          elif isinstance(exc, MissingRequiredArgument):
              await ctx.send(&quot;One or more required arguments are missing.&quot;)
  
          elif isinstance(exc, CommandOnCooldown):
              await ctx.send(f&quot;That command is on {str(exc.cooldown.type).split('.')[-1]} cooldown. Try again in {exc.retry_after:,.2f} secs.&quot;)
  
          elif hasattr(exc, &quot;original&quot;):
              # if isinstance(exc.original, HTTPException):
              #   await ctx.send(&quot;Unable to send message.&quot;)
  
              if isinstance(exc.original, Forbidden):
                  await ctx.send(&quot;I do not have permission to do that.&quot;)
  
              else:
                  raise exc.original
  
          else:
              raise exc
  
      async def on_ready(self):
          if not self.ready:
              self.stdout = self.get_channel(759434903145152533)
              self.scheduler.add_job(self.rules_reminder, CronTrigger(
                  day_of_week=0, hour=12, minute=0, second=0))
              self.scheduler.start()
  
              self.update_db()
  
              embed = Embed(title=&quot;Now Online&quot;,
                              description=&quot;Bobby Bot is now online.&quot;, timestamp=datetime.utcnow())
              fields = [(&quot;Name&quot;, &quot;Bobby Bot&quot;, True),
                          (&quot;Latency&quot;, str(round(bot.latency * 1000)) + &quot;ms&quot;, True)]
              for name, value, inline in fields:
                  embed.add_field(name=name, value=value, inline=inline)
              embed.set_author(name=&quot;Bobby Bot&quot;, icon_url=&quot;https://cdn.discordapp.com/attachments/794376573213736991/887527732228018276/Bobbys.png&quot;)
              embed.set_thumbnail(url=&quot;https://cdn.discordapp.com/attachments/794376573213736991/887527732228018276/Bobbys.png&quot;)
              await self.stdout.send(embed=embed)
  
              while not self.cogs_ready.all_ready():
                  await sleep(0.5)
  
              await self.stdout.send(&quot;Now online!&quot;)
              self.ready = True
              print(&quot; bot ready&quot;)
  
              meta = self.get_cog(&quot;Meta&quot;)
              await meta.set()
  
          else:
              print(&quot;bot reconnected&quot;)
  
      async def on_message(self, message):
          if not message.author.bot:
              if isinstance(message.channel, DMChannel):
                  if len(message.content) &lt; 50:
                      await message.channel.send(&quot;Your message should be at least 50 characters in length.&quot;)
  
                  else:
                      member = self.guild.get_member(message.author.id)
                      embed = Embed(title=&quot;Modmail&quot;,
                                    colour=member.colour,
                                    timestamp=datetime.utcnow())
  
                      embed.set_thumbnail(url=member.avatar_url)
  
                      fields = [(&quot;Member&quot;, member.display_name, False),
                                (&quot;Message&quot;, message.content, False)]
  
                      for name, value, inline in fields:
                          embed.add_field(name=name, value=value, inline=inline)
                      
                      mod = self.get_cog(&quot;Mod&quot;)
                      await mod.log_channel.send(embed=embed)
                      await message.channel.send(&quot;Message relayed to moderators.&quot;)
  
              else:
                  await self.process_commands(message)
  
  
  bot = Bot()
  </code></pre>
  <p>No matter what I try it keeps coming up with the same error regardless of the fact that I know I followed the vid tutorial I was going through exactly. I can't find why it's not recognising self</p>