GithubHelp home page GithubHelp logo

Plugin dependencies about enhanceddiscord HOT 8 OPEN

joe27g avatar joe27g commented on July 19, 2024
Plugin dependencies

from enhanceddiscord.

Comments (8)

jakub-studio avatar jakub-studio commented on July 19, 2024

In addition to this, I would like to see some kind of ED.onPluginsLoaded event implemented so that plugins that create global variables as some sort of APIs would be easier to work with,

nvm.

from enhanceddiscord.

rauenzi avatar rauenzi commented on July 19, 2024

I'm not sure there are really many plugins that need dependencies. Mine do of course, but they automatically check for the dependency and let you know if it exists. To have a dependency system, really the best way would cause some restructures of how plugins work in ED. Ideally there would be a separate config files that states plugin info including dependencies that way dependencies can be checked and ensured even before the plugin itself is required that way it can ensure no errors occur and that plugins can require their dependency at any time (as opposed to during load() which would be necessary if sticking with current structure and adding dependencies.)

That being said, either way of moving forwards would require rewriting the current plugin loader. So it would really be up to you guys and Joe how you would want to move forward (if at all).

@jakuski an event like that would be simple enough. But realistically for most dependency cases shouldn't be needed. For instance if I had a plugin that wanted to use ZeresUtils.js I could simply do require("ZeresUtils") and anything exported would be available to you, e.g. static functions and such would immediately be available without the plugin having had load() fired.

from enhanceddiscord.

jakub-studio avatar jakub-studio commented on July 19, 2024

@rauenzi I was thinking more of something like this

Plugin A is lets say, a chat command plugin.
Plugin B is a plugin that shows you all emojis in a guild for example.

Plugin A creates a global variable called ChatCommands and any can plugin can utilise it and make their own chat commands.

However due to the way plugins are required/loaded, Plugin B doesn't know when the global variable ChatCommands will be ready and instead of a while (!ChatCommands) sleep... I think that having a event fire off, (Not really a NodeEventEmitter since I see multiple issues with it when it comes to multiple plugins utilisng it.) will be better for speeds sake.

So instead of Plugin B having to integrate it's own way of UI, it could simply wait for ED's plugins to be loaded and if the chat command global var is not there, throw a error.

If it is there, then it could register a chatcommand to show guild emojis.

Example:

module.exports = new Plugin({
    load () {
        ED.onPluginsLoaded(() => {
            // do something
        })
    }
})

or maybe

module.exports = new Plugin({
    load () {}
    onPluginsLoaded () {
            // do something
    })
})

from enhanceddiscord.

rauenzi avatar rauenzi commented on July 19, 2024

well in ChatCommands you could do this

const myPlugin = new Plugin({});
myPlugin.commands = [];
module.exports = myPlugin;

and in another plugin called Shrug you can do this

module.exports = new Plugin({
    load () {
        const commands = require("ChatCommands").commands;
        commands.push("my new command");
    }
});

that should work fine since it all refers to the same object.

from enhanceddiscord.

jakub-studio avatar jakub-studio commented on July 19, 2024

Only issue I see with this is user's renaming the file (which is what the ED.plugins key's are based off.)

from enhanceddiscord.

rauenzi avatar rauenzi commented on July 19, 2024

You can never fully eliminate pebkac errors, that can happen even with a dependency scheme.

from enhanceddiscord.

joe27g avatar joe27g commented on July 19, 2024

I can sort of see a use for this, but have no idea how to implement it at this time. Hence the 'status:delayed'.

from enhanceddiscord.

rauenzi avatar rauenzi commented on July 19, 2024

I could help with implementing this, but like I said above it depends on the structuring you want to go with.

from enhanceddiscord.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.