Ejemplo n.º 1
0
 async def cog_command_error(self, ctx: Context, error: CommandError):
     # TODO: More comprehensive list of errors and proper handlers
     if isinstance(error, MissingRequiredArgument):
         return await KaiserModule.send_error(
             ctx, f'Missing Argument',
             'The command you tried to run ({ctx.message.content}), requires an argument you didn\'t provide: {error}'
         )
     Logger.warning(f'Error in {self.name}: {error}')
Ejemplo n.º 2
0
 async def on_command_error(self, ctx: Context, error: CommandError):
     if isinstance(error, CommandNotFound):
         return await KaiserModule.send_error(
             ctx, 'Command Not Found',
             f'The command you tried to run ({ctx.message.content}), does not exist'
         )
     # TODO: More comprehensive list of errors and proper handlers
     Logger.warning(f'Unhandled error type {type(error)}')
     await KaiserModule.send_error(ctx)
Ejemplo n.º 3
0
    def database_read(self,
                      key: str,
                      field: str = 'UserData',
                      user_id: int = 0,
                      subfield_override=False):
        if subfield_override:
            if not subfield_override == 'Common':
                Logger.warning("Cross-module database access is discouraged")
        else:
            subfield_override = self.name

        if field == 'UserData':
            return Database.database[field][user_id][subfield_override][key]
        else:
            return Database.database[field][subfield_override][key]
Ejemplo n.º 4
0
 async def on_ready(self):
     Logger.info(f'Kasier loaded in {time() - Kaiser.started_at} seconds')
Ejemplo n.º 5
0
 def load_module(self, module_init: Callable):
     module = module_init(self)
     Logger.info(f'Loading module {module.name}...')
     self.add_cog(module_init(self))
Ejemplo n.º 6
0
    @classmethod
    async def on_command_error(self, ctx: Context, error: CommandError):
        if isinstance(error, CommandNotFound):
            return await KaiserModule.send_error(
                ctx, 'Command Not Found',
                f'The command you tried to run ({ctx.message.content}), does not exist'
            )
        # TODO: More comprehensive list of errors and proper handlers
        Logger.warning(f'Unhandled error type {type(error)}')
        await KaiserModule.send_error(ctx)


if __name__ == '__main__':
    Kaiser.started_at = time()
    Logger.info('Starting...')

    argparser = ArgumentParser(description=Kaiser.description)
    argparser.add_argument('-o',
                           '--outfile',
                           help='the log file to output to',
                           dest='logfile',
                           type=str,
                           default=None)
    argparser.add_argument('-d',
                           '--datafile',
                           help='the database json file to use',
                           dest='database',
                           type=str,
                           default=None)
    args = argparser.parse_args()
Ejemplo n.º 7
0
 def cog_unload(self):
     Logger.info(f'Unloading module {self.name}')