Create plugin_template.js
Browse files- plugin_template.js +30 -0
plugin_template.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export default function(client,app,special){
|
| 2 |
+
// client: https://docs.wwebjs.dev/Client.html
|
| 3 |
+
// app: https://expressjs.com/en/4x/api.html
|
| 4 |
+
|
| 5 |
+
client.on('message_create',async msg=>{
|
| 6 |
+
let texto=msg.body.toString();
|
| 7 |
+
//Chequear que lo.hemos enviado al mensaje y empieza con el identificador
|
| 8 |
+
if(!msg.fromMe || !texto.startsWith(special.prefix)) return;
|
| 9 |
+
//Quitamos el identificador y obtenemos el comando y sus argumentos
|
| 10 |
+
let args=texto.slice(special.prefix.length).split(" ");
|
| 11 |
+
let comando = args.shift();
|
| 12 |
+
args=args.join(" ").split("|");
|
| 13 |
+
switch(comando){
|
| 14 |
+
case "saludar":
|
| 15 |
+
await msg.reply("Hola!");
|
| 16 |
+
break;
|
| 17 |
+
case "echo":
|
| 18 |
+
await msg.reply(args.join("|"));
|
| 19 |
+
break;
|
| 20 |
+
default:
|
| 21 |
+
return;
|
| 22 |
+
break; //No se si este break va, pero por las dudas
|
| 23 |
+
}
|
| 24 |
+
});
|
| 25 |
+
return {name:`Nombre del plugin(Será visto en ${special.prefix}help)`,
|
| 26 |
+
comandos:[
|
| 27 |
+
{name:"saludar",description:"Saludar, este comando no requiere argumentos"},
|
| 28 |
+
{name:"echo",description:"Este comando repite todo lo escrito luego",args:["[texto]"]}
|
| 29 |
+
]}
|
| 30 |
+
}
|