{
  "name": "8ball",
  "author": "limon",
  "supportedGames": [
    "all"
  ],
  "takaroVersion": "development",
  "versions": [
    {
      "tag": "latest",
      "description": "Allows players to use a Magic 8-Ball command to receive random fortune-telling responses to their questions.\n\n  **Key Functionality:**\n\n  * **8-Ball Command:** Players can use a designated command (default: `8ball`) to ask the Magic 8-Ball a question.\n  * **Random Responses:** The module provides a list of configurable responses. When the command is used, the module selects a random response from this list and displays it to the player.\n  * **Configurable Output:** The module allows server administrators to choose whether the 8-Ball's response is sent as a global server message or as a private message (PM) to the player.\n  * **Customizable Responses:** The list of 8-Ball responses can be fully customized, allowing server administrators to tailor the module to their server's theme or language.\n  * **Permission Control:** Usage of the 8-Ball command can be restricted using a configurable permission.\n\n  **How to Use:**\n\n  1.  **Configuration:**\n      * `sendMessage`:  Choose whether the 8-Ball's response is sent as a `serverMessage` (to all players) or a `playerPM` (private message to the player who used the command).\n      * `responses`:  Edit the array of strings to customize the 8-Ball's possible answers. Ensure there is at least one response.\n  2.  **Permissions:** Assign the `MAGIC_8BALL_USE` permission to the player groups or individuals who should be able to use the `8ball` command.\n  3.  **In-Game Usage:** Players use the `/8ball` command (or the configured trigger) followed by their question. The 8-Ball's response will be displayed according to the `sendMessage` configuration.\n\n  **Important Considerations:**\n\n  * Ensure there is at least one response in the `responses` configuration to avoid errors.\n  * Customize the responses to fit your server's style and language.\n  * Use the permission system to control who can use the command.\n",
      "configSchema": "{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"type\":\"object\",\"required\":[],\"additionalProperties\":false,\"properties\":{\"sendMessage\":{\"title\":\"sendMessage\",\"description\":\"Decide on sending it to the server globally or to the individual player\",\"default\":\"serverMessage\",\"type\":\"string\",\"enum\":[\"serverMessage\",\"playerPM\"]},\"responses\":{\"title\":\"responses\",\"description\":\"Here you can edit the responses of the 8ball command. \\n\",\"default\":[\"It is certain\",\"Without a doubt\",\"You may rely on it\",\"Most likely\",\"Yes\",\"No\",\"Signs point to yes\",\"Reply hazy, try again\",\"Ask again later\",\"Better not tell you now\",\"Cannot predict now\",\"Don't count on it\",\"My sources say no\",\"Very doubtful\",\"Outlook not so good\"],\"type\":\"array\",\"items\":{\"type\":\"string\"},\"minItems\":1,\"maxItems\":1000}}}",
      "uiSchema": "{}",
      "commands": [
        {
          "name": "my-command",
          "trigger": "8ball",
          "helpText": "No help text available",
          "function": "import { takaro, data, checkPermission, TakaroUserError } from '@takaro/helpers';\n\nasync function main() {\n    // Check permission first\n    if (!checkPermission(data.pog, 'MAGIC_8BALL_USE')) {\n        throw new TakaroUserError('You do not have permission to use the magic 8-ball!');\n    }\n\n    const { sendMessage, responses } = data.module.userConfig;\n\n    // Get random response\n    const response = responses[Math.floor(Math.random() * responses.length)];\n    const messageText = `🎱 ${data.player.name} asked the magic 8-ball: ${response}`;\n\n    // Send message based on config\n    if (sendMessage === 'serverMessage') {\n        await takaro.gameserver.gameServerControllerSendMessage(data.gameServerId, {\n            message: messageText\n        });\n    } else if (sendMessage === 'playerPM') {\n        await data.player.pm(messageText);\n    }\n}\n\nawait main();",
          "arguments": []
        }
      ],
      "hooks": [],
      "cronJobs": [],
      "functions": [],
      "permissions": [
        {
          "permission": "MAGIC_8BALL_USE",
          "friendlyName": "MAGIC_8BALL_USE",
          "description": "This permissions allows your players to use the Magic 8Ball",
          "canHaveCount": false
        }
      ]
    }
  ]
}