registerPlugin({
name: "Demo Script",
version: "0.1",
description: "Demo Script",
author: "DrWarpMan <[email protected]>",
backends: ["ts3"],
engine: ">= 1.0",
autorun: false,
enableWeb: false,
hidden: false,
requiredModules: [],
vars: [],
voiceCommands: []
}, (_, config, meta) => {
const backend = require("backend");
const engine = require("engine");
const event = require("event");
const store = require("store");
/*
Amount => the amount of how many times you have used that command, I could not find any better word for this,
so just that you know that what amount is :D
I have not tested it, it may have typos, and it may not even start, or work - give me feedback
*/
event.on("chat", ev => {
// This is my way how to make command and arguments from text message
let message = ev.text.split(" ").filter(i => /\s/.test(i) === false && i.length > 0); // Get text from event, split the text ( message ), remove multiple spaces
let command = message[0].toLowerCase(); // Get command from the message
let args = message.slice(1).join(" "); // Get args from message (after first space) - IGNORE THIS
let client = ev.client; // Get client from event
if (command === "!mycmd") {
if (getCommandAmount(client, command) < 10) // If command was used less than 10 times
{
addCommandAmount(client, command); // Add command amount
} else {
client.chat("Nope, you can not write this command anymore!"); // If reached max. (10 times)
}
}
});
function getCommandAmount(client, command) {
return store.get(client.uid() + " " + command) || 0; // Get current amount from store, if undefined - return 0
}
function addCommandAmount(client, command) {
let currentAmount = getCommandAmount(client, command); // Get current amount
currentAmount++; // Increase current amount
store.set(client.uid() + " " + command, currentAmount); // Store current amount
client.chat("Command amount added!"); // Message that command amount was added succesfully!;
}
// SCRIPT LOADED SUCCCESFULLY - this is what I use in every single script of mine, (inspired by irgendwr)
engine.log("[Script] \"" + meta.name + "\" [Version] \"" + meta.version + "\" [Author] \"" + meta.author + "\"");
});