BetterDiscord:如何制作插件?

BetterDiscord:如何制作插件?,discord,Discord,因此,我找到了一个示例插件脚本: //META{"name":"Example"}*// class Example { // Constructor constructor() { this.initialized = false; } // Meta getName() { return "Example"; } getShortName() { return &q

因此,我找到了一个示例插件脚本:

//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");
    }
}
//META{“name”:“Example”}*//
课例{
//建造师
构造函数(){
this.initialized=false;
}
//元
getName(){return“Example”;}
getShortName(){return“Example”;}
getDescription(){return“这是BD插件的示例/模板。”;}
getVersion(){返回“0.1.0”;}
getAuthor(){返回“Minin”;}
//设置面板
getSettingsPanel(){
返回“”;
}
//装载/卸载
加载(){}
卸载(){}
//事件
onMessage(){
PluginUtilities.showtoos(“新消息!”)
};
onSwitch(){
//在切换服务器或通道时调用
};
观察员(e){
//每个突变的原始突变观察者事件
};
//启动/停止
开始(){
var libraryScript=document.getElementById('zeresLibraryScript');
如果(!libraryScript){
libraryScript=document.createElement(“脚本”);
setAttribute(“type”、“text/javascript”);
libraryScript.setAttribute(“src”https://rauenzi.github.io/BetterDiscordAddons/Plugins/PluginLibrary.js");
setAttribute(“id”、“zeresLibraryScript”);
文档.头.附件子项(libraryScript);
}
if(typeof window.ZeresLibrary!=“未定义”)this.initialize();
else libraryScript.addEventListener(“加载”,()=>{this.initialize();});
}
停止(){
PluginUtilities.showToast(this.getName()+“”+this.getVersion()+”已停止。:(“”;
};
//初始化
初始化(){
this.initialized=true;
PluginUtilities.showToast(this.getName()+“”+this.getVersion()+”已启动:D:D);
}
}
我还收到一个“示例无法卸载”错误

请帮助,因为没有在线教程(
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀

我不确定它到底出了什么问题,但下面是一个工作代码的示例

 /**
 * @name PLugin Name
 * @version 0.0.1
 * @description Example Description
 * @author Username and/or tag
 *  
 */



   module.exports = class name{
     
       load() { }
       start() {

//your code


}
stop(){
  
}
}
是我使用的模板,对我来说很好

下面是我制作的一个小插件的一个例子,它只是为了尝试一下

    /**
 * @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(){

}
}
/**
*@name吉菲德
*@version 0.0.2
*@description厌倦了看gif?藏起来!
*@作者:2305#7876
*   
*/
//https://media.tenor.co/videos/af68e294135a577e8f4aa52a1f94f3e7/mp4
module.exports=类gifider{
加载(){}
开始(){
var b;
var-LOCK=false;
BdApi.alert(BdApi.React.createElement(“输入”{
风格:{
颜色:“白色”,
背景:“36393f”
},
类名:“InpArg”
}));
setInterval(函数(){
var inp=document.querySelector(“.InpArg”)
if(inp!=未定义的| | inp!=null&&LOCK==false){
LOCK=true
b=inp;
console.log(b.value)
}否则{
var计数=0;
if(document.getElementsByTagName(“视频”).length>0){
做{
if(document.getElementsByTagName(“视频”)[count].src==b.value){
//console.log(“Gif阻止”);
document.getElementsByTagName(“视频”)[count].style.display='none';
}
否则{
//控制台日志(“假”);
}
计数++;
}而