{
  "name": "chatBridge",
  "author": "Takaro",
  "supportedGames": [
    "all"
  ],
  "takaroVersion": ">=0.0.1",
  "versions": [
    {
      "tag": "0.0.1",
      "description": "Connect chat to other services like Discord.",
      "configSchema": "{\"$schema\":\"http://json-schema.org/draft-07/schema#\",\"type\":\"object\",\"properties\":{\"sendPlayerConnected\":{\"title\":\"Send player connected\",\"type\":\"boolean\",\"description\":\"Send a message when a player connects.\",\"default\":true},\"sendPlayerDisconnected\":{\"title\":\"Send player disconnected\",\"type\":\"boolean\",\"description\":\"Send a message when a player disconnects.\",\"default\":true},\"onlyGlobalChat\":{\"title\":\"Only global chat\",\"type\":\"boolean\",\"default\":true,\"description\":\"Only relay messages from global chat. (no team chat or private messages)\"}},\"additionalProperties\":false}",
      "uiSchema": "{}",
      "commands": [],
      "hooks": [
        {
          "name": "DiscordToGame",
          "eventType": "discord-message",
          "description": "Hook for discord-message events",
          "regex": null,
          "function": "import { takaro, data } from '@takaro/helpers';\nasync function main() {\n    try {\n        if (data.eventData.author.isBot) {\n            return;\n        }\n        await takaro.gameserver.gameServerControllerSendMessage(data.gameServerId, {\n            message: `[D] ${data.eventData.author.displayName}:  ${data.eventData.msg}`,\n        });\n    }\n    catch (error) {\n        console.error(error);\n        await takaro.discordControllerSendMessage(data.discordChannelId, {\n            message: 'Failed to forward your message to the game. Please try again later.',\n        });\n    }\n}\nawait main();\n//# sourceMappingURL=DiscordToGame.js.map"
        },
        {
          "name": "GameToDiscord",
          "eventType": "chat-message",
          "description": "Hook for chat-message events",
          "regex": null,
          "function": "import { takaro, data } from '@takaro/helpers';\nasync function main() {\n    const onlyGlobal = data.module.userConfig.onlyGlobalChat;\n    if (onlyGlobal && data.eventData.channel !== 'global') {\n        return;\n    }\n    const discordChannel = data.module.systemConfig.hooks.DiscordToGame.discordChannelId;\n    const sender = data.player ? data.player.name : 'Non-player';\n    const message = `**${sender}**: ${data.eventData.msg}`;\n    await takaro.discord.discordControllerSendMessage(discordChannel, {\n        message: message,\n    });\n}\nawait main();\n//# sourceMappingURL=GameToDiscord.js.map"
        },
        {
          "name": "PlayerConnected",
          "eventType": "player-connected",
          "description": "Hook for player-connected events",
          "regex": null,
          "function": "import { takaro, data } from '@takaro/helpers';\nasync function main() {\n    const discordChannel = data.module.systemConfig.hooks.DiscordToGame.discordChannelId;\n    await takaro.discord.discordControllerSendMessage(discordChannel, {\n        message: `[⚡ Connected]: ${data.player.name}`,\n    });\n}\nawait main();\n//# sourceMappingURL=PlayerConnected.js.map"
        },
        {
          "name": "PlayerDisconnected",
          "eventType": "player-disconnected",
          "description": "Hook for player-disconnected events",
          "regex": null,
          "function": "import { takaro, data } from '@takaro/helpers';\nasync function main() {\n    const discordChannel = data.module.systemConfig.hooks.DiscordToGame.discordChannelId;\n    await takaro.discord.discordControllerSendMessage(discordChannel, {\n        message: `[👋 Disconnected]: ${data.player.name}`,\n    });\n}\nawait main();\n//# sourceMappingURL=PlayerDisconnected.js.map"
        }
      ],
      "cronJobs": [],
      "functions": [],
      "permissions": []
    }
  ]
}