diff options
author | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2021-10-31 09:49:42 +0800 |
---|---|---|
committer | Soopyboo32 <49228220+Soopyboo32@users.noreply.github.com> | 2021-10-31 09:49:42 +0800 |
commit | 48653ec89538f1650106a5e77463412cad4684c2 (patch) | |
tree | 09687cd579462e04d539fd4615369fa6dae13902 /features/fragBot | |
download | SoopyV2-48653ec89538f1650106a5e77463412cad4684c2.tar.gz SoopyV2-48653ec89538f1650106a5e77463412cad4684c2.tar.bz2 SoopyV2-48653ec89538f1650106a5e77463412cad4684c2.zip |
first commit
Diffstat (limited to 'features/fragBot')
-rw-r--r-- | features/fragBot/index.js | 84 | ||||
-rw-r--r-- | features/fragBot/metadata.json | 8 |
2 files changed, 92 insertions, 0 deletions
diff --git a/features/fragBot/index.js b/features/fragBot/index.js new file mode 100644 index 0000000..67bb9a3 --- /dev/null +++ b/features/fragBot/index.js @@ -0,0 +1,84 @@ +/// <reference types="../../../CTAutocomplete" /> +/// <reference lib="es2015" /> +import Feature from "../../featureClass/class"; +import SettingBase from "../settings/settingThings/settingBase"; +import ToggleSetting from "../settings/settingThings/toggle"; + +class FragBot extends Feature { + constructor() { + super() + } + + onEnable(){ + this.initVariables() + + this.hostingFragBot = false + this.fragBotQueue = [] + this.commandQueue = [] + + new SettingBase("To host a fragbot use /fragbot", "", undefined, "host_fragbot_info", this) + + this.uploadToWebsite = new ToggleSetting("Advertise fragbot status", "Will show up as a fragbot in other peoples fragbot lists", true, "advertise_fragbot", this) + + this.registerCommand("fragbot", this.fragbotCommand) + + this.registerStep(false, 5, this.step) + this.registerStep(true, 2, this.step2) + + this.registerChat("&9&m-----------------------------&r&9\n&r${player} &r&ehas invited you to join their party!\n&r&eYou have &r&c60 &r&eseconds to accept. &r&6Click here to join!&r&9\n&r&9&m-----------------------------&r", this.recievedPartyInvite) + } + + step(){ + if(!this.hostingFragBot) return + + if(this.fragBotQueue.length > 0){ + let player = this.fragBotQueue.shift() + if(player){ + this.commandQueue.push("/party leave") + + this.commandQueue.push("/party accept " + player) + } + } + } + step2(){ + if(!this.hostingFragBot) return + + if(this.commandQueue.length > 0){ + let command = this.commandQueue.shift() + if(command){ + ChatLib.say(command) + } + } + } + recievedPartyInvite(player){ + if(!this.hostingFragBot) return + + player = ChatLib.removeFormatting(player).split(" ").pop() + + this.fragBotQueue.push(player) + } + + fragbotCommand(...args){ + if(this.hostingFragBot){ + this.hostingFragBot = false + ChatLib.chat("&aFragbot has been disabled") + }else{ + this.hostingFragBot = true + ChatLib.chat("&aNow acting as a fragbot, run /fragbot again to disable") + } + } + + initVariables(){ + this.hostingFragBot = undefined + this.fragBotQueue = undefined + this.commandQueue = undefined + } + + onDisable(){ + this.initVariables() + } +} + +module.exports = { + class: new FragBot() +}
\ No newline at end of file diff --git a/features/fragBot/metadata.json b/features/fragBot/metadata.json new file mode 100644 index 0000000..5aaa6a9 --- /dev/null +++ b/features/fragBot/metadata.json @@ -0,0 +1,8 @@ +{ + "name": "Frag Bot", + "description": "Features to assist using fragbots, or to host one", + "isHidden": false, + "isTogglable": true, + "defaultEnabled": true, + "sortA": 1 +}
\ No newline at end of file |