title: Why I`m getting this TypeError?
body: <p>I am trying to create a getprefix command, which changes the server prefix. I`m using an sql database to store prefixes. I am getting the following error when I send any message in a server, not only bot commands:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;C:\Users\tudor\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py&quot;, line 835, in get_prefix
      ret = list(ret)
  TypeError: 'NoneType' object is not iterable
  
  During handling of the above exception, another exception occurred:
  
  Traceback (most recent call last):
    File &quot;C:\Users\tudor\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\client.py&quot;, line 343, in _run_event
      await coro(*args, **kwargs)
    File &quot;C:\Users\tudor\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py&quot;, line 979, in on_message
      await self.process_commands(message)
    File &quot;C:\Users\tudor\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py&quot;, line 975, in process_commands
      ctx = await self.get_context(message)
    File &quot;C:\Users\tudor\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py&quot;, line 886, in get_context
      prefix = await self.get_prefix(message)
    File &quot;C:\Users\tudor\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py&quot;, line 842, in get_prefix
      raise TypeError(&quot;command_prefix must be plain string, iterable of strings, or callable &quot;
  TypeError: command_prefix must be plain string, iterable of strings, or callable returning either of these, not NoneType
  
  </code></pre>
  <p>My code:</p>
  <pre><code>
  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)
  </code></pre>
  <p>My database code:</p>
  <pre><code>from os.path import isfile
  from sqlite3 import connect
  
  from apscheduler.triggers.cron import CronTrigger
  
  DB_PATH = &quot;./data/db/database.db&quot;
  BUILD_PATH = &quot;./data/db/build.sql&quot;
  
  cxn = connect(DB_PATH, check_same_thread=False)
  cur = cxn.cursor()
  
  
  def with_commit(func):
      def inner(*args, **kwargs):
          func(*args, **kwargs)
          commit()
  
      return inner
  
  
  @with_commit
  def build():
      if isfile(BUILD_PATH):
          scriptexec(BUILD_PATH)
  
  
  def commit():
      cxn.commit()
  
  
  def autosave(sched):
      sched.add_job(commit, CronTrigger(second=0))
  
  
  def close():
      cxn.close()
  
  
  def field(command, *values):
      cur.execute(command, tuple(values))
  
      if (fetch := cur.fetchone()) is not None:
          return fetch[0]
  
  
  def record(command, *values):
      cur.execute(command, tuple(values))
  
      return cur.fetchone()
  
  
  def records(command, *values):
      cur.execute(command, tuple(values))
  
      return cur.fetchall()
  
  
  def column(command, *values):
      cur.execute(command, tuple(values))
  
      return [item[0] for item in cur.fetchall()]
  
  
  def execute(command, *values):
      cur.execute(command, tuple(values))
  
  
  def multiexec(command, valueset):
      cur.executemany(command, valueset)
  
  
  def scriptexec(path):
      with open(path, &quot;r&quot;, encoding=&quot;utf-8&quot;) as script:
          cur.executescript(script.read())
  </code></pre>
  <p>The first time I`ve tried this it worked perfectly with the same code: I was able to update custom prefixes for servers in the database without any errors.</p>