import logging

from lib.database import Database
from lib.utils import emojify


class Command(object):
    def __init__(self, bot, config):
        self.bot = bot
        self._config = config

        self.name = self.__get_name()
        self.description = self.__get_description()
        if not self.name or not self.description:
            self._logger.error('Command is missing required attribute \'name\' or \'description\''.format(__name__))
            del self
            return

        self._logger = logging.getLogger('pyper.command.' + self.name)

        if self.__has_database():
            self._database = Database('data/{0}.json'.format(self.name))

        self.aliases = self.__get_aliases()
        self.admin_only = self.__is_admin_only()

    def authorized(self, user):
        if self.admin_only:
            return self.bot.is_admin(user)
        return True

    def reply(self, message, reply, **kwargs):
        if 'disable_web_page_preview' not in kwargs:
            kwargs['disable_web_page_preview'] = True

        if 'emojify' in kwargs and kwargs['emojify']:
            reply = emojify(reply)
            del kwargs['emojify']

        if type(reply) is list:
            reply = ' '.join(reply)

        self.bot.telegram.reply_to(message, reply, **kwargs)

    def __has_database(self):
        if hasattr(self, 'has_database'):
            return self.has_database
        return False

    def __is_admin_only(self):
        if hasattr(self, 'admin_only'):
            return self.admin_only
        return False

    def __get_name(self):
        if hasattr(self, 'name'):
            return self.name
        return None

    def __get_description(self):
        if hasattr(self, 'description'):
            return self.description
        return None

    def __get_aliases(self):
        return self.aliases if hasattr(self, 'aliases') else []

@@ -9,16 +9,38 @@
 ogging%0A%0A
+import os%0Aimport sys%0A%0A
 from lib
@@ -631,22 +631,16 @@
     
-self._
 database
  = D
@@ -639,28 +639,51 @@
 base
- = Database('
+_path = os.path.realpath('%7B0%7D/../../
 data/%7B
-0
+1
 %7D.js
@@ -693,26 +693,200 @@
 .format(
-self.name)
+os.path.realpath(sys.argv%5B0%5D), self.name))%0A            self._logger.debug('Storing database for %25s at %25s', self.name, database_path)%0A            self._database = Database(database_path
 )%0A%0A     
@@ -972,16 +972,76 @@
 n_only()
+%0A        self._logger.debug('Loaded command %25s.', self.name)
 %0A%0A    de

Add command init logging