Skip to content

Your First Plugin

A nekocord plugin is a simple JavaScript class that implements the Plugin interface. Here is an example of a built-in plugin that would be placed in the src/plugins directory:

ExamplePlugin.ts
import { Plugin } from "../../api/PluginManager";
import { Nekocord } from "../../renderer/main";
export class ExamplePlugin implements Plugin {
info = {
name: "Example Plugin",
id: "nekohaxx:example-plugin",
authors: [{ name: "nekohaxx", id: "1176270221628153886" }],
description: "Example plugin",
version: "0.1.0",
patches: [
// your patches here
]
}
constructor(nekocord: Nekocord) {
// your constructor here
}
onEnable() {
// this is called once on startup if it was previously enabled, and also called when the user manually toggles it on
}
onDisable() {
// this is called when the plugin is disabled (if the user manually toggles it off)
}
onRegister() {
// this is called once when the plugin is registered
}
userPreferences: any;
onPreferencesChange(userPreferences: any): void {
this.userPreferences = userPreferences;
// any preferences change handling here
}
}

Dynamically loaded plugins are placed in (nekocord data)/plugins directory with the extension .nkplugin.js. The plugin manager will load all enabled plugins in this directory when nekocord starts, applying patches to Discord’s modules.

You can read the full Plugin API documentation for more information on the Plugin interface and how to use it.