{
  "name": "CPMStaffCommands",
  "author": "Mad",
  "supportedGames": [
    "all"
  ],
  "takaroVersion": "v0.0.21",
  "versions": [
    {
      "tag": "0.0.1",
      "description": "Provides a set of moderator commands for enhanced server management, especially useful alongside the CPM (CSMM Patrons Mod). These commands offer tools for player moderation, world manipulation, and server administration.\n\n  ## Key Functionality\n\n  * **Player Management:**\n      * `/kill <playerTarget>`: Instantly kills the specified player (requires confirmation).\n      * `/mute <player> <reason>`: Mutes a player in chat with a specified reason.\n      * `/unmute <player>`: Unmutes a player.\n      * `/arrest <player> <reason>`: Places a player in a designated jail area with a reason.\n      * `/release <player>`: Releases a player from jail.\n      * `/pull <player>`: Teleports the specified player to the moderator's location.\n      * `/rpd <player>`: Resets the specified player's data (use with extreme caution).\n      * `/wi <player> <tool>`: Wipes a player's inventory (`belt`, `bag`, `equipment`, or `all`).\n  * **Player Buffs/Debuffs:**\n      * `/buff <player>`: Temporarily grants god-like powers to a player.\n      * `/debuff <player>`: Removes specified debuffs from a player.\n  * **World Manipulation:**\n      * `/pr`: Resets the current Point of Interest (POI).\n      * `/reset1`: Sets the first corner for chunk reset.\n      * `/reset2`: Resets chunks between the first and second corners.\n      * `/killall`: Kills all zombies on the server.\n      * `/visitmap`: Opens the server map (requires CPM functionality).\n  * **Server Control:**\n      * `/shutdownba <minutes>`: Shuts down the server after a specified delay.\n\n  ## How to Use\n\n  1.  **Installation:** Install the module on your Takaro instance.\n  2.  **CPM Requirement:** This module is designed to enhance 7 Days to Die servers using the CSMM Patrons Mod (CPM). While some commands may function without it, full functionality is not guaranteed.\n  3.  **Discord Integration (Optional):**\n      * Configure the `userDiscordChannel` setting to enable Discord notifications for certain moderation actions (e.g., bans, kicks, mutes).\n  4.  **Permissions:** Grant the `STAFF_COMMANDS` permission to the player groups or individuals who should have access to these moderator commands.  Individual commands may have their own permissions as well.\n\n  5.  **In-Game Usage:** Moderators can use the commands as described in the \"Key Functionality\" section. Pay close attention to the specific syntax and arguments required for each command (e.g., using quotes around player names with spaces).\n\n  ## Important Considerations\n\n  * **CPM Compatibility:** The module's functionality may depend on the specific version and configuration of the CSMM Patrons Mod.  Ensure compatibility to avoid issues.\n  * **Permission Management:** Use the provided permissions to restrict access to these powerful moderator commands.  Incorrect usage can disrupt the game experience.\n  * **Confirmation:** Some commands (e.g., `/kill`, `/rpd`) require confirmation to prevent accidental execution due to their potentially destructive nature.\n  * **Discord Setup:** If using Discord notifications, ensure that your Takaro instance is properly configured to communicate with your Discord server.\n",
      "configSchema": "{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"type\":\"object\",\"required\":[],\"additionalProperties\":false,\"properties\":{\"discordChannel\":{\"title\":\"discordChannel\",\"description\":\"Sends to discord\",\"type\":\"string\"}}}",
      "uiSchema": "{}",
      "commands": [
        {
          "name": "kill",
          "trigger": "kill",
          "helpText": "kill (players name), use quotes for names with spaces",
          "function": "import { takaro, data, checkPermission, TakaroUserError } from '@takaro/helpers';\n\nasync function main() {\n    const { player, gameServerId, pog, module: mod, arguments: args } = data;\n    const playerTarget = args.playerTarget;\n\n    // Check permissions first\n    if (!checkPermission(pog, 'STAFF_COMMANDS')) {\n        throw new TakaroUserError('You do not have permission to use [02FEDC]Moderator[-] commands.');\n    }\n\n    // Check if there's an existing confirmation variable\n    const confirmationKey = `kill_confirmation_${playerTarget}`;\n    const existingConfirmation = await takaro.variable.variableControllerSearch({\n        filters: {\n            key: [confirmationKey],\n            gameServerId: [gameServerId],\n            playerId: [pog.playerId],\n            moduleId: [mod.moduleId]\n        }\n    });\n\n    // If confirmation variable exists, proceed with kill\n    if (existingConfirmation.data.data.length > 0) {\n        // Delete the confirmation variable first\n        await takaro.variable.variableControllerDelete(existingConfirmation.data.data[0].id);\n\n        // Execute the kill command\n        const response = (await takaro.gameserver.gameServerControllerExecuteCommand(gameServerId, {\n            command: `kill \"${playerTarget}\"`,\n        })).data.data.rawResult;\n\n        if (response.includes('Targetplayer is offline')) {\n            throw new TakaroUserError(`[02FEDC]${playerTarget}[-] is not online`);\n        }\n\n        await player.pm(`You have killed [02FEDC]${playerTarget}[-].`);\n    } else {\n        // Create confirmation variable with 30 second expiry\n        const now = new Date();\n        const expiry = new Date(now.getTime() + 30 * 1000); // 30 seconds from now\n\n        await takaro.variable.variableControllerCreate({\n            key: confirmationKey,\n            value: JSON.stringify({ expiry: expiry.toISOString() }),\n            gameServerId,\n            moduleId: mod.moduleId,\n            playerId: pog.playerId\n        });\n\n        // Send confirmation message\n        await player.pm(`Are you sure you want to kill [02FEDC]${playerTarget}[-]? Run the command again within 30 seconds to confirm.`);\n    }\n}\n\nawait main();",
          "arguments": [
            {
              "name": "playerTarget",
              "type": "string",
              "helpText": "The player you want to kill",
              "defaultValue": "",
              "position": 0
            }
          ]
        },
        {
          "name": "release",
          "trigger": "release",
          "helpText": "No help text available",
          "function": "import { takaro, data, checkPermission, TakaroUserError } from '@takaro/helpers';\nasync function main() {\n    const { gameServerId, player } = data;\n    const { arguments: args } = data;\n\n    //Check Permissions\n    if (!checkPermission(pog, 'STAFF_COMMANDS')) {\n        throw new TakaroUserError('You do not have permission to use [02FEDC]Moderator[-] commmands.');\n    }\n\n    //Execute Command arrest\n    await takaro.gameserver.gameServerControllerExecuteCommand(gameServerId, {\n        command: `release \"${args.playerTarget}\"`,\n    });\n\n    if (response.includes('is not a valid entity id, player name or user id')) {\n        throw new TakaroUserError(`[02FEDC]${args.playerTarget}[-]'s name wasn't spelled correctly! Use quotes if their name has spaces!`)\n    };\n\n    //Send global message in game to shame the offender\n    await takaro.gameserver.gameServerControllerSendMessage(data.gameServerId, {\n        message: `${args.playerTarget} has been released. Please follow the rules!`,\n    });\n};\nawait main();\n//# sourceMappingURL=visit.js.map",
          "arguments": []
        },
        {
          "name": "avisit",
          "trigger": "avisit",
          "helpText": "Teleport to a friend",
          "function": "import { takaro, data, checkPermission, TakaroUserError } from '@takaro/helpers';\n\nasync function main() {\n    const { player, gameServerId, pog, arguments: args } = data;\n    const playerTarget = args.playerTarget;\n\n    if (!checkPermission(pog, 'STAFF_COMMANDS')) {\n        throw new TakaroUserError('You do not have permission to use [02FEDC]Moderator[-] commmands.');\n    }\n\n    const response = (await takaro.gameserver.gameServerControllerExecuteCommand(gameServerId, {\n        command: `teleportplayer \"${player.name}\" \"${playerTarget}\"`,\n    })).data.data.rawResult;\n\n    if (response.includes('Targetplayer is offline')) {\n        throw new TakaroUserError(`[02FEDC]${playerTarget}[-] is not online`);\n    }\n\n    // Send success message to the player\n    await player.pm(`Successfully teleported to [02FEDC]${playerTarget}[-]`);\n}\n\nawait main();",
          "arguments": [
            {
              "name": "playerTarget",
              "type": "string",
              "helpText": "Player teleporting to",
              "defaultValue": "",
              "position": 0
            }
          ]
        },
        {
          "name": "arrest",
          "trigger": "arrest",
          "helpText": "No help text available",
          "function": "import { takaro, data, checkPermission, TakaroUserError } from '@takaro/helpers';\nasync function main() {\n    const { gameServerId, player } = data;\n    const { arguments: args } = data;\n\n    //Check Permissions\n    if (!checkPermission(pog, 'STAFF_COMMANDS')) {\n        throw new TakaroUserError('You do not have permission to use [02FEDC]Moderator[-] commmands.');\n    }\n\n    //Execute Command arrest\n    await takaro.gameserver.gameServerControllerExecuteCommand(gameServerId, {\n        command: `arrest \"${args.playerTarget}\"`,\n    });\n\n    if (response.includes('is not a valid entity id, player name or user id')) {\n        throw new TakaroUserError(`[02FEDC]${args.playerTarget}[-]'s name wasn't spelled correctly!`);\n    }\n\n    //Send global message in game to shame the offender\n    await takaro.gameserver.gameServerControllerSendMessage(data.gameServerId, {\n        message: `${args.playerTarget} was arrested for ${args.reasoning}`,\n    });\n};\nawait main();\n//# sourceMappingURL=visit.js.map",
          "arguments": [
            {
              "name": "playerTarget",
              "type": "string",
              "helpText": "Other player's name",
              "defaultValue": "",
              "position": 0
            }
          ]
        },
        {
          "name": "ban",
          "trigger": "ban",
          "helpText": "ban (name, use quotes if there's a space) (reason in quotes)",
          "function": "import { takaro, data, checkPermission, TakaroUserError } from '@takaro/helpers';\n\nasync function main() {\n    const { player, gameServerId, pog, arguments: args } = data;\n    const { person, reasoning } = args;\n    const discordChannel = data.module.userConfig.discordChannel;\n    if (!checkPermission(pog, 'STAFF_COMMANDS')) {\n        throw new TakaroUserError('You do not have permission to use [02FEDC]Moderator[-] commmands.');\n    }\n\n    const response = (await takaro.gameserver.gameServerControllerExecuteCommand(gameServerId, {\n        command: `ban add \"${person}\" 1 year \"${reasoning}\" \"${person}\"`,\n    })).data.data.rawResult;\n\n    if (response.includes('is not a valid entity id, player name or user id')) {\n        throw new TakaroUserError(`[02FEDC]${person}[-]'s name wasn't spelled correctly!`);\n    }\n\n    //Confirmation\n    await player.pm(`[02FEDC]${person}[-] was banned.`);\n\n    await takaro.discord.discordControllerSendMessage(discordChannel, {\n        message: `🔨 ${player.name} banned ${person} for ${reasoning}.`,\n    });\n}\n\nawait main();",
          "arguments": [
            {
              "name": "reasoning",
              "type": "string",
              "helpText": "Reason they are banned",
              "defaultValue": "No reason given",
              "position": 1
            },
            {
              "name": "person",
              "type": "string",
              "helpText": "Person being banned",
              "defaultValue": "",
              "position": 0
            }
          ]
        },
        {
          "name": "unmute",
          "trigger": "unmute",
          "helpText": "unmute (players name, use quotes for names with spaces)",
          "function": "import { takaro, data, checkPermission, TakaroUserError } from '@takaro/helpers';\n\nasync function main() {\n    const { player, gameServerId, pog, arguments: args } = data;\n    const { person, reasoning } = args;\n    const discordChannel = data.module.userConfig.discordChannel;\n    if (!checkPermission(pog, 'STAFF_COMMANDS')) {\n        throw new TakaroUserError('You do not have permission to use [02FEDC]Moderator[-] commmands.');\n    }\n\n    const response = (await takaro.gameserver.gameServerControllerExecuteCommand(gameServerId, {\n        command: `mcp \"${person}\" false`,\n    })).data.data.rawResult;\n\n    if (response.includes('is not a valid entity id, player name or user id')) {\n        throw new TakaroUserError(`[02FEDC]${person}[-]'s name wasn't spelled correctly!`);\n    }\n\n    //Confirmation\n    await player.pm(`[02FEDC]${person}[-] was unmuted.`);\n\n    await takaro.discord.discordControllerSendMessage(discordChannel, {\n        message: `🤐 ${player.name} unmuted ${person}.`,\n    });\n}\n\nawait main();",
          "arguments": [
            {
              "name": "person",
              "type": "string",
              "helpText": "player to be unmuted",
              "defaultValue": "",
              "position": 0
            }
          ]
        },
        {
          "name": "mute",
          "trigger": "mute",
          "helpText": "Mute (players name, use quotes when there's aspace) (reason in quotes)",
          "function": "import { takaro, data, checkPermission, TakaroUserError } from '@takaro/helpers';\n\nasync function main() {\n    const { player, gameServerId, pog, arguments: args } = data;\n    const { person, reasoning } = args;\n    const discordChannel = data.module.userConfig.discordChannel;\n    if (!checkPermission(pog, 'STAFF_COMMANDS')) {\n        throw new TakaroUserError('You do not have permission to use [02FEDC]Moderator[-] commmands.');\n    }\n\n    const response = (await takaro.gameserver.gameServerControllerExecuteCommand(gameServerId, {\n        command: `mcp \"${person}\" true`,\n    })).data.data.rawResult;\n\n    if (response.includes('is not a valid entity id, player name or user id')) {\n        throw new TakaroUserError(`[02FEDC]${person}[-]'s name wasn't spelled correctly!`);\n    }\n\n    //Confirmation\n    await player.pm(`[02FEDC]${person}[-] was muted.`);\n\n    await takaro.discord.discordControllerSendMessage(discordChannel, {\n        message: `🤐 ${player.name} muted ${person} for ${reasoning}.`,\n    });\n}\n\nawait main();",
          "arguments": [
            {
              "name": "reasoning",
              "type": "string",
              "helpText": "Reason they were muted",
              "defaultValue": "No reason given",
              "position": 1
            },
            {
              "name": "person",
              "type": "string",
              "helpText": "Person to be muted",
              "defaultValue": "",
              "position": 0
            }
          ]
        },
        {
          "name": "rdd",
          "trigger": "rdd",
          "helpText": "No help text available",
          "function": "import { takaro, data, checkPermission, TakaroUserError } from '@takaro/helpers';\n\nasync function main() {\n    const { player, gameServerId, pog, arguments: args } = data;\n    const playerTarget = args.playerTarget;\n\n    if (!checkPermission(pog, 'STAFF_COMMANDS')) {\n        throw new TakaroUserError('You do not have permission to use [02FEDC]Moderator[-] commmands.');\n    }\n\n    const response = (await takaro.gameserver.gameServerControllerExecuteCommand(gameServerId, {\n        command: `rdd \"${playerTarget}\"`,\n    })).data.data.rawResult;\n\n    if (response.includes('Targetplayer is offline')) {\n        throw new TakaroUserError(`[02FEDC]${playerTarget}[-] is not online`);\n    }\n}\n\nawait main();",
          "arguments": [
            {
              "name": "playerTarget",
              "type": "string",
              "helpText": "Person drone data is being reset for",
              "defaultValue": "",
              "position": 0
            }
          ]
        },
        {
          "name": "kick",
          "trigger": "kick",
          "helpText": "type kick (name, in quotes is they have a space) (reason in quotes). Example kick \"El Linón\" \"Too cool\"",
          "function": "import { takaro, data, checkPermission, TakaroUserError } from '@takaro/helpers';\n\nasync function main() {\n    const { player, gameServerId, pog, arguments: args } = data;\n    const { person, reasoning } = args;\n    const discordChannel = data.module.userConfig.discordChannel;\n    if (!checkPermission(pog, 'STAFF_COMMANDS')) {\n        throw new TakaroUserError('You do not have permission to use [02FEDC]Moderator[-] commmands.');\n    }\n\n    const response = (await takaro.gameserver.gameServerControllerExecuteCommand(gameServerId, {\n        command: `kick \"${person}\" \"${reasoning}\"`,\n    })).data.data.rawResult;\n\n    if (response.includes('is not a valid entity id, player name or user id')) {\n        throw new TakaroUserError(`[02FEDC]${person}[-]'s name wasn't spelled correctly!`);\n    }\n\n    //Confirmation\n    await player.pm(`[02FEDC]${person}[-] was kicked.`);\n\n    await takaro.discord.discordControllerSendMessage(discordChannel, {\n        message: `🥾 ${player.name} kicked ${person} for ${reasoning}`,\n    });\n}\n\nawait main();",
          "arguments": [
            {
              "name": "reasoning",
              "type": "string",
              "helpText": "Reason for being kicked",
              "defaultValue": "Contact a moderator for a kick reason",
              "position": 1
            },
            {
              "name": "person",
              "type": "string",
              "helpText": "Player getting kicked",
              "defaultValue": "",
              "position": 0
            }
          ]
        }
      ],
      "hooks": [],
      "cronJobs": [],
      "functions": [],
      "permissions": [
        {
          "permission": "STAFF_COMMANDS",
          "friendlyName": "Staff Commands",
          "description": "Commands for staff to use without using Currency",
          "canHaveCount": false
        }
      ]
    }
  ]
}