const
    {app} = require('electron'),
    fs = require('fs-extra'),
    Path = require('path'),
    klaw = require('klaw-sync');

var PluginManager = {
    loadedPlugins: {},

    LoadPlugins: function(mod, appEvents) {
        var pluginFolders = fs.readdirSync( Path.resolve(app.getAppPath() + '/plugins') )

        pluginFolders.forEach((pluginFolder) => {
            var pluginPath = Path.resolve('plugins', pluginFolder);

            if(fs.statSync(pluginPath).isDirectory()) {
                loadPlugin(pluginPath, mod, appEvents);
            }
        });
    }
}

function loadPlugin(dir, mod) {
    const pluginManifestPath = Path.resolve(dir, 'package.json');

    // Register the plugin
    var pluginManifest = fs.readJsonSync(pluginManifestPath);
    PluginManager.loadedPlugins[pluginManifest.name] = {
        manifest: pluginManifest,
        module: mod.require(dir)
    };

    // Execute the plugin's initial script
    PluginManager.loadedPlugins[pluginManifest.name].module.init();
}

module.exports = PluginManager;

const
    {app} = require('electron'),
    fs = require('fs-extra'),
    Path = require('path'),
    klaw = require('klaw-sync');

var PluginManager = {
    loadedPlugins: {},

    LoadPlugins: function(mod, appEvents) {
        var pluginFolders = fs.readdirSync( Path.resolve(app.getAppPath() + '/plugins') )

        pluginFolders.forEach((pluginFolder) => {
            var pluginPath = Path.resolve('plugins', pluginFolder);

            if(fs.statSync(pluginPath).isDirectory()) {
                loadPlugin(pluginPath, mod, appEvents);
            }
        });
    }
}

function loadPlugin(dir, mod) {
    const pluginManifestPath = Path.resolve(dir, 'package.json');

    // Register the plugin
    var pluginManifest = fs.readJsonSync(pluginManifestPath);
    PluginManager.loadedPlugins[pluginManifest.name] = {
        manifest: pluginManifest,
        module: mod.require(dir)
    };

    // Execute the plugin's initial script
    PluginManager.loadedPlugins[pluginManifest.name].module()
}

module.exports = PluginManager;

Change init function to what the plugin exports
Change init function to what the plugin exports

Plugins should no longer export an object with an init function, but rather just the init function itself which gets run on plugin load
