So I found a example plugin script:
//META{"name":"Example"}*//
class Example {
// Constructor
constructor() {
this.initialized = false;
}
// Meta
getName() { return "Example"; }
getShortName() { return "Example"; }
getDescription() { return "This is an example/template for a BD plugin."; }
getVersion() { return "0.1.0"; }
getAuthor() { return "Minin"; }
// Settings Panel
getSettingsPanel() {
return "<!--Enter Settings Panel Options, just standard HTML-->";
}
// Load/Unload
load() { }
unload() { }
// Events
onMessage() {
PluginUtilities.showToast("New message!")
};
onSwitch() {
// Called when a server or channel is switched
};
observer(e) {
// raw MutationObserver event for each mutation
};
// Start/Stop
start() {
var libraryScript = document.getElementById('zeresLibraryScript');
if (!libraryScript) {
libraryScript = document.createElement("script");
libraryScript.setAttribute("type", "text/javascript");
libraryScript.setAttribute("src", "https://rauenzi.github.io/BetterDiscordAddons/Plugins/PluginLibrary.js");
libraryScript.setAttribute("id", "zeresLibraryScript");
document.head.appendChild(libraryScript);
}
if (typeof window.ZeresLibrary !== "undefined") this.initialize();
else libraryScript.addEventListener("load", () => { this.initialize(); });
}
stop() {
PluginUtilities.showToast(this.getName() + " " + this.getVersion() + " has stopped. :( :(");
};
// Initialize
initialize() {
this.initialized = true;
PluginUtilities.showToast(this.getName() + " " + this.getVersion() + " has started. :D :D");
}
}
I get an "Example could not be unloaded" error too. ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
I'm not really sure whats wrong with it but here is an example of working code.
/**
* @name PLugin Name
* @version 0.0.1
* @description Example Description
* @author Username and/or tag
*
*/
module.exports = class name{
load() { }
start() {
//your code
}
stop(){
}
}
is the template i use, it works fine for me.
Here is an example of a small plugin i made that works just to try it out.
/**
* @name GifHider
* @version 0.0.2
* @description tired of looking at a gif? hide it!
* @author Archer2305#7876
*
*/
//https://media.tenor.co/videos/af68e294135a577e8f4aa52a1f94f3e7/mp4
module.exports = class Gifhider{
load() { }
start() {
var b;
var LOCK= false;
BdApi.alert(BdApi.React.createElement("input", {
style: {
color: "white",
background:"#36393f"
},
className:"InpArg"
}));
setInterval(function() {
var inp= document.querySelector(".InpArg")
if(inp!=undefined||inp!=null&&LOCK==false){
LOCK=true
b= inp;
console.log(b.value)
} else{
var count = 0;
if (document.getElementsByTagName("video").length>0){
do {
if (document.getElementsByTagName("video")[count].src==b.value) {
//console.log("Gif blocked");
document.getElementsByTagName("video")[count].style.display = 'none';
}
else {
//console.log("false");
}
count++;
} while (count<document.getElementsByTagName("video").length)
}
}
}, 1);
}
stop(){
}
}