Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

1. General Plugin Structure

12944qwerty edited this page Sep 6, 2022 · 5 revisions

Structure of a Plugin

A simple Plugin usually consists of 2 files, index.js and manifest.json.

The Structure of your plugin should look like this for it to work, additional files and folders can be created but this is the bare minimum to get it to work

🗀 example-plugin
 |_ manifest.json
 |_ index.js

manifest.json

A file called manifest.json is required in every Plugin and provides Replugged with information about your plugin, an example manifest.json file with all available fields would look like this

{
  "name": "Example Name",
  "version": "1.0.0",
  "description": "My Plugin does this",
  "author": "DiscordName#0001",
  "license": "MIT",
  "nsfw": false,
  "permissions": "ext_api"
}

The name, version, description, author and license Attributes are Required for your plugin to work.

The version attribute can be set to 0.xxx or xxx-beta to show up as "Beta".

The nsfw attribute has to be set to true if your Plugin uses Content considered Not Safe for Work, "permissions": "exp_api" has to be included an if you use an API not provided by replugged.dev

index.js

The index.js file is the heart of your Plugin, as this is the only file Replugged tries to run, it should unite every file you need for your Plugin. This is the Base required for your Plugin to work.

const { Plugin } = require("powercord/entities");

module.exports = class PluginName extends Plugin {
  startPlugin() {
    // Initializing Here
  }
  pluginWillUnload() {
    // Unloading Here
  }
}

Time to take a closer Look at this.

with const { Plugin } = require("powercord/entities"); we grab Replugged's Plugin class and use it in the Line Below to tell Replugged that this is a Plugin. PluginName should be changed by you to match your Plugin.

The startPlugin() method is called as soon as the Plugin starts and should be Used to Initialize Injections, commands or Settings (More to Injections, commands and Settings Later)

The pluginWillUnload() method is called when the Plugin unloads and should be used to do some cleanup like Uninjecting and unregistering Commands/Settings.

Additional methods will be covered in a different section