Updated information to make development more convenient for newcomers to the project.
parent
d64369e364
commit
c372419d0b
|
@ -1,6 +1,9 @@
|
|||
##API functions provided by BetterDiscord, BetterAPI and webSock
|
||||
This should help you if you want to write a plugin yourself :)
|
||||
You should also check out the [testPlugin.js](https://github.com/Bluscream/BetterDiscord-Plugins-and-Themes/blob/master/plugins/testPlugin.plugin.js).
|
||||
##Building a plugin
|
||||
Take a look at the [Example Plugin](https://gist.github.com/Jiiks/71edd5af0beafcd08956) for a template
|
||||
|
||||
Checkout some of the plugins from the official [BetterDiscord Repository](https://github.com/Jiiks/BetterDiscordApp/blob/master/Plugins).
|
||||
|
||||
If you're interested in highly random and experimental plugins, checkout [BlueScreams Repository](https://github.com/Bluscream/BetterDiscord-Plugins-and-Themes/tree/master/plugins)
|
||||
|
||||
Currently available [BdApi](https://github.com/Jiiks/BetterDiscordApp/blob/master/js/bdapi.js) functions:
|
||||
```js
|
||||
|
@ -12,5 +15,44 @@ BdApi.getIpc();
|
|||
BdApi.getCore();
|
||||
BdApi.getUserIdByName("name");
|
||||
BdApi.getUserNameById("id");
|
||||
//BdApi.setPlaying("game"); Disabled for now
|
||||
//BdApi.setStatus("status"); Disabled for now
|
||||
Core.prototype.alert("title", "text")
|
||||
```
|
||||
```
|
||||
|
||||
##Details
|
||||
|
||||
####Plugins are limited to one file.
|
||||
There can be multiple files in the BetterDiscord plugins directory, but to prevent junk and prevent future collisions,
|
||||
it is best practice to include your entire plugin within one .js file.
|
||||
|
||||
####Plugins have a special identifier
|
||||
BetterDiscord requires two lines at the beginning of a plugin file to identify it:
|
||||
```
|
||||
//META{"name":"testPlugin"}*//
|
||||
function testPlugin() {}
|
||||
```
|
||||
|
||||
Without these, your plugin will not be identified by BD properly and will not show up in the list.
|
||||
|
||||
|
||||
####Discord isn't just a browser
|
||||
Discord is node.js and chromium as one. BetterDiscord plugins can use all native node.js functions and modules.
|
||||
It is possible to include pure js node modules within your plugin using webpack. Any modules that require
|
||||
compilation and/or do not have pure js alternatives will of course not work.
|
||||
|
||||
####Plugins are susceptible to throttling.
|
||||
By default, Discord will throttle plugins when Discord is minimized.
|
||||
Currently there are no in-plugin workarounds to fix this.
|
||||
Throttling is the same as chromium, functions like setInterval and setTimeout will be throttled to at least 1000ms
|
||||
|
||||
####Add namespaces to your events.
|
||||
When creating selectors like $(document).on('dblclick'), instead use a namespace such as
|
||||
$(document).on('dblclick.dce') in order to easily unload the event with $(document).off("dblclick.dce")
|
||||
without unloading all dblclick events.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue