text: from twitchbot import (
      Command,
      Message,
      cfg,
      InvalidArgumentsError
  )
  
  from database.models import Quote
  
  from database.quotes import (
      delete_quote_by_id,
      add_quote,
      get_quote,
      get_random_quote
  )
  
  PREFIX = cfg.prefix
  
  
  @Command('addquote',
           syntax='"<quote text>"',
           help='adds a quote to the database')
  async def cmd_add_quote(msg: Message, *args):
      if not args:
          raise InvalidArgumentsError(
              reason='missing required arguments', cmd=cmd_add_quote)
  
      quote_msg = f'"{args[0]}" {" ".join(args[1:])}'
  
      quote = Quote.create(
          channel=msg.channel_name, quote=quote_msg, added_by=msg.author)
      if add_quote(quote):
          resp = f'successfully added quote #{quote.id}'
      else:
          resp = 'failed to add quote, already exist'
  
      await msg.reply(resp)
  
  
  @Command('quote',
           syntax='[none] or id',
           help='returns random quote or quote by id')
  async def cmd_get_quote(msg: Message, *args):
      if not args:
          quote = get_random_quote(msg.channel.name)
      else:
          quote = get_quote(msg.channel_name, args[0])
  
      if quote is None:
          resp = 'no quote found'
      elif type(quote) is str:
          resp = quote
      else:
          resp = f'{quote.id}: {quote.quote}, {quote.date_added.year}'
  
      await msg.reply(resp)
  
  
  @Command('delquote', permission='delete_quote', syntax='id',
           help='deletes the quote from the database')
  async def cmd_del_quote(msg: Message, *args):
      if not args:
          raise InvalidArgumentsError(
              reason='missing required argument', cmd=cmd_del_quote)
  
      quote = get_quote(msg.channel_name, args[0])
      if quote is None:
          raise InvalidArgumentsError(
              reason='no quote found', cmd=cmd_del_quote)
  
      delete_quote_by_id(msg.channel_name, quote.id)
      await msg.reply(
          f'successfully deleted quote, id: {quote.id}')
  