{
  "name": "CPMStaffCommands",
  "author": "Mad",
  "supportedGames": [
    "all"
  ],
  "takaroVersion": "v0.0.21",
  "versions": [
    {
      "tag": "0.0.2",
      "description": "# MAD_CPMStaffCommands Module",
      "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": "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": "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": "person",
              "type": "string",
              "helpText": "Person to be muted",
              "defaultValue": "",
              "position": 0
            },
            {
              "name": "reasoning",
              "type": "string",
              "helpText": "Reason they were muted",
              "defaultValue": "No reason given",
              "position": 1
            }
          ]
        },
        {
          "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": "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": "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": "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": "person",
              "type": "string",
              "helpText": "Player getting kicked",
              "defaultValue": "",
              "position": 0
            },
            {
              "name": "reasoning",
              "type": "string",
              "helpText": "Reason for being kicked",
              "defaultValue": "Contact a moderator for a kick reason",
              "position": 1
            }
          ]
        },
        {
          "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": "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": "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
            }
          ]
        }
      ],
      "hooks": [],
      "cronJobs": [],
      "functions": [],
      "permissions": [
        {
          "permission": "STAFF_COMMANDS",
          "friendlyName": "Staff Commands",
          "description": "Commands for staff to use without using Currency",
          "canHaveCount": false
        }
      ]
    }
  ]
}