feat: gitignored src/userplugins directory (#112)
This commit is contained in:
parent
5a18292d92
commit
9d6021f0b9
4 changed files with 34 additions and 11 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -16,3 +16,5 @@ yarn-error.log*
|
||||||
lerna-debug.log*
|
lerna-debug.log*
|
||||||
.pnpm-debug.log*
|
.pnpm-debug.log*
|
||||||
*.tsbuildinfo
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
src/userplugins
|
||||||
|
|
|
@ -26,6 +26,14 @@ pnpm buildWeb
|
||||||
|
|
||||||
You will find the built extension at dist/extension.zip. Now just install this extension in your Browser
|
You will find the built extension at dist/extension.zip. Now just install this extension in your Browser
|
||||||
|
|
||||||
|
## Installing Plugins
|
||||||
|
|
||||||
|
Vencord comes with a bunch of plugins out of the box!
|
||||||
|
However, if you want to install your own ones, create a `userplugins` folder in the `src` directory and create or clone your plugins in there.
|
||||||
|
Don't forget to rebuild!
|
||||||
|
|
||||||
|
Want to learn how to create your own plugin, and maybe PR it into Vencord? See the [Contributing](#contributing) section below!
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
See [CONTRIBUTING.md](CONTRIBUTING.md) and [Megu's Plugin Guide!](docs/2_PLUGINS.md)
|
See [CONTRIBUTING.md](CONTRIBUTING.md) and [Megu's Plugin Guide!](docs/2_PLUGINS.md)
|
||||||
|
|
|
@ -6,7 +6,9 @@ You don't need to run `pnpm build` every time you make a change. Instead, use `p
|
||||||
|
|
||||||
## Plugin Entrypoint
|
## Plugin Entrypoint
|
||||||
|
|
||||||
1. Create a folder in `src/plugins/` with the name of your plugin. For example, `src/plugins/epicPlugin/` - All of your plugin files will go here.
|
> If it doesn't already exist, create a folder called `userplugins` in the `src` directory of this repo.
|
||||||
|
|
||||||
|
1. Create a folder in `src/userplugins/` with the name of your plugin. For example, `src/userplugins/epicPlugin/` - All of your plugin files will go here.
|
||||||
|
|
||||||
2. Create a file in that folder called `index.ts`
|
2. Create a file in that folder called `index.ts`
|
||||||
|
|
||||||
|
@ -20,7 +22,7 @@ export default definePlugin({
|
||||||
description: "This plugin is absolutely epic",
|
description: "This plugin is absolutely epic",
|
||||||
authors: [
|
authors: [
|
||||||
{
|
{
|
||||||
id: "your discord user id goes here",
|
id: 12345n,
|
||||||
name: "Your Name",
|
name: "Your Name",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -33,6 +35,8 @@ export default definePlugin({
|
||||||
|
|
||||||
Change the name, description, and authors to your own information.
|
Change the name, description, and authors to your own information.
|
||||||
|
|
||||||
|
Replace `12345n` with your user ID ending in `n` (e.g., `545581357812678656n`). If you don't want to share your Discord account, use `0n` instead!
|
||||||
|
|
||||||
## How Plugins Work In Vencord
|
## How Plugins Work In Vencord
|
||||||
|
|
||||||
Vencord uses a different way of making mods than you're used to.
|
Vencord uses a different way of making mods than you're used to.
|
||||||
|
@ -97,7 +101,9 @@ abc.isStaff = function () {
|
||||||
|
|
||||||
The match value _can_ be a string, rather than regex, however usually regex will be better suited, as it can work with unknown values, whereas strings must be exact matches.
|
The match value _can_ be a string, rather than regex, however usually regex will be better suited, as it can work with unknown values, whereas strings must be exact matches.
|
||||||
|
|
||||||
Once you've made your plugin, make sure you run `pnpm lint` and make sure your code is nice and clean, and then open a PR on github :)
|
Once you've made your plugin, make sure you run `pnpm test` and make sure your code is nice and clean!
|
||||||
|
|
||||||
|
If you want to publish your plugin into the Vencord repo, move your plugin from `src/userplugins` into the `src/plugins` folder and open a PR!
|
||||||
|
|
||||||
> **Warning**
|
> **Warning**
|
||||||
> Make sure you've read [CONTRIBUTING.md](../CONTRIBUTING.md) before opening a PR
|
> Make sure you've read [CONTRIBUTING.md](../CONTRIBUTING.md) before opening a PR
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { execSync } from "child_process";
|
import { execSync } from "child_process";
|
||||||
import esbuild from "esbuild";
|
import esbuild from "esbuild";
|
||||||
|
import { existsSync } from "fs";
|
||||||
import { readdir } from "fs/promises";
|
import { readdir } from "fs/promises";
|
||||||
|
|
||||||
const watch = process.argv.includes("--watch");
|
const watch = process.argv.includes("--watch");
|
||||||
|
@ -41,21 +42,27 @@ export const globPlugins = {
|
||||||
});
|
});
|
||||||
|
|
||||||
build.onLoad({ filter: /^plugins$/, namespace: "import-plugins" }, async () => {
|
build.onLoad({ filter: /^plugins$/, namespace: "import-plugins" }, async () => {
|
||||||
const files = await readdir("./src/plugins");
|
const pluginDirs = ["plugins", "userplugins"];
|
||||||
let code = "";
|
let code = "";
|
||||||
let plugins = "\n";
|
let plugins = "\n";
|
||||||
for (let i = 0; i < files.length; i++) {
|
let i = 0;
|
||||||
if (files[i] === "index.ts") {
|
for (const dir of pluginDirs) {
|
||||||
continue;
|
if (!existsSync(`./src/${dir}`)) continue;
|
||||||
|
const files = await readdir(`./src/${dir}`);
|
||||||
|
for (const file of files) {
|
||||||
|
if (file === "index.ts") {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
const mod = `p${i}`;
|
||||||
|
code += `import ${mod} from "./${dir}/${file.replace(/.tsx?$/, "")}";\n`;
|
||||||
|
plugins += `[${mod}.name]:${mod},\n`;
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
const mod = `p${i}`;
|
|
||||||
code += `import ${mod} from "./${files[i].replace(/.tsx?$/, "")}";\n`;
|
|
||||||
plugins += `[${mod}.name]:${mod},\n`;
|
|
||||||
}
|
}
|
||||||
code += `export default {${plugins}};`;
|
code += `export default {${plugins}};`;
|
||||||
return {
|
return {
|
||||||
contents: code,
|
contents: code,
|
||||||
resolveDir: "./src/plugins"
|
resolveDir: "./src"
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue