Add cloop command
This commit is contained in:
parent
6e28176bda
commit
b49427cab7
4 changed files with 51 additions and 0 deletions
|
@ -22,6 +22,7 @@ botvX or UBot is a Minecraft bot for [Kaboom](https://kaboom.pw/) and its clones
|
|||
|-|-|-|
|
||||
| about | | About the bot |
|
||||
| cb | \<command\> | Run a command in a command block |
|
||||
| cb | add <rate> <command>, remove <index>, list, clear | Run a command in a command block |
|
||||
| eval | \<code\> | Run JavaScript code (must run through console)|
|
||||
| help | [cmd] | Shows command help |
|
||||
| logoff | | Disconnect and reconnect the bot from a server |
|
||||
|
|
36
plugins/commands/cloop.js
Normal file
36
plugins/commands/cloop.js
Normal file
|
@ -0,0 +1,36 @@
|
|||
const getMessage = require('../../util/lang.js')
|
||||
module.exports={
|
||||
execute: (c)=>{
|
||||
const subcmd=c.args.splice(0,1)[0];
|
||||
switch(subcmd){
|
||||
case "add":
|
||||
const rate=+(c.args.splice(0,1)[0]);
|
||||
const command=c.args.join(" ");
|
||||
if(rate<20){
|
||||
c.reply({text:getMessage(c.lang,"command.cloop.error.tooShort")})
|
||||
}
|
||||
c.bot.addCloop(command,rate)
|
||||
c.reply({text:getMessage(c.lang,"command.cloop.success.add",[command,rate+""])})
|
||||
break
|
||||
case "remove":
|
||||
const index=+c.args[0];
|
||||
c.bot.removeCloop(c.args[0]);
|
||||
c.reply({text:getMessage(c.lang,"command.cloop.success.remove",[index+""])})
|
||||
break
|
||||
case "list":
|
||||
for(const i in c.bot.cloops){
|
||||
c.reply({text:getMessage(c.lang,"command.cloop.list",[i,c.bot.cloops[i].command,c.bot.cloops[i].rate+""])})
|
||||
}
|
||||
break
|
||||
case "clear":
|
||||
c.bot.clearCloops();
|
||||
c.reply({text:getMessage(c.lang,"command.cloop.success.clear")})
|
||||
break
|
||||
default:
|
||||
c.reply(`Unknown subcommand, please do ${c.prefix}help cloop`)
|
||||
}
|
||||
},
|
||||
hidden: true,
|
||||
consoleIndex: true,
|
||||
level: 1
|
||||
}
|
|
@ -3,6 +3,8 @@
|
|||
"command.about.desc": "About the bot",
|
||||
"command.cb.usage": " <command>",
|
||||
"command.cb.desc": "Run a command in a command block",
|
||||
"command.cloop.usage": " add <rate> <command>|| remove <index>|| list|| clear",
|
||||
"command.cloop.desc": "Manage command loops",
|
||||
"command.eval.usage": " <code>",
|
||||
"command.eval.desc": "Run JavaScript code",
|
||||
"command.help.usage": " [cmd]",
|
||||
|
@ -26,6 +28,11 @@
|
|||
"command.about.author": "%s - a Minecraft bot made by 77c8f4699b732c11 / a5a06d596f15c7db",
|
||||
"command.about.version": "Version %s",
|
||||
"command.about.serverinfo": "To view system information, run the command \"serverinfo\".",
|
||||
"command.cloop.error.tooShort": "Command loops must have a rate above 20ms.",
|
||||
"command.cloop.success.add": "Added command loop with command %s and rate %s",
|
||||
"command.cloop.success.remove": "Removed command loop %s",
|
||||
"command.cloop.success.clear": "Cleared all command loops",
|
||||
"command.cloop.list": "%s: Command: %s Rate: %s",
|
||||
"command.help.cmdList": "Commands: %s",
|
||||
"command.help.commandInfo": "%s%s - %s",
|
||||
"command.help.commandUsage": "Usage - %s%s",
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
"command.about.desc": "About the bot",
|
||||
"command.cb.usage": " <command>",
|
||||
"command.cb.desc": "Wun a command in a command bwock",
|
||||
"command.cloop.usage": " add <wate> <command>|| remove <index>|| list|| clear",
|
||||
"command.cloop.desc": "Manage command woops",
|
||||
"command.eval.usage": " <code>",
|
||||
"command.eval.desc": "Wun JavaScwipt code",
|
||||
"command.help.usage": " [cmd]",
|
||||
|
@ -26,6 +28,11 @@
|
|||
"command.about.author": "%s - a Minyecwaft bot made by 77c8f4699b732c11 / a5a06d596f15c7db",
|
||||
"command.about.version": "Vewsion %s",
|
||||
"command.about.serverinfo": "To view system infowmation, wun the command \"serverinfo\".",
|
||||
"command.cloop.error.tooShort": "Command woops must have a wate above 20ms.",
|
||||
"command.cloop.success.add": "Added command woop with command %s and wate %s",
|
||||
"command.cloop.success.remove": "Wemoved command woop %s",
|
||||
"command.cloop.success.clear": "Cweawed aww command woops",
|
||||
"command.cloop.list": "%s: Command: %s Rate: %s",
|
||||
"command.help.cmdList": "Commands: %s",
|
||||
"command.help.commandInfo": "%s%s - %s",
|
||||
"command.help.commandUsage": "Usage - %s%s",
|
||||
|
|
Loading…
Reference in a new issue