Skip to content

Creating Your Own Plugin

Adek edited this page Aug 14, 2021 · 6 revisions

Create Your Own Plugin

We try our best to simplify module creation.

All you needed is your <plugin_name>.py file in the plugins folder (anjani/custom_plugins/).

Then create a SubClass that inherited the plugin.Plugin import from from anjani import plugin.
After that give your subclass a class variable named name with the plugin name unless the plugin name will be "Unnamed".

from anjani import plugin

class ExamplePlugin(plugin.Plugin):
    name = "Example"

For more information about Class you can read here

Adding a Command Handler To The Plugin

If you are not fan of annotating your code you simply don't need to import anything to register the command,
you just need to create a Coroutine function name that starts with cmd_[name] and takes 2 parameters,
self refers to the SubClass you create and ctx refers to ~command.Context.

    async def cmd_example(self, ctx):
        return "My own custom Plugins!"

Then the command for interacting with the bot will be /example
and it will respond you message with text the return of that function My own custom Plugins!.

*Read more about plugin attributes & method.

Clone this wiki locally