{
  "name": "chatbridge",
  "author": "limon",
  "supportedGames": [
    "all"
  ],
  "takaroVersion": "main",
  "versions": [
    {
      "tag": "latest",
      "description": "# Limon_chatbridge: Discord Chat Integration for Your Game Server\n\nThis module bridges your game server's chat and a Discord channel, enabling two-way communication with powerful, customizable filtering options.\n\n## Key Features\n\n*   **Two-Way Chat Relay:** Forward messages between your game and Discord in real-time. Improve player interaction and build a stronger community.\n*   **Player Connection/Disconnection Notifications:** Optionally send automated Discord messages when players join or leave your server.\n*   **Advanced Filtering Options:**\n    *   **Global Chat Only:** Restrict messages to your game's global chat channel, excluding team chat and private messages.\n    *   **Command Filtering:** Prevent in-game command messages (e.g., `/ban`) from cluttering your Discord.\n    *   **System Message Filtering:** Keep your Discord clean by blocking system (non-player) messages.\n*   **Dedicated Monitoring Channel (Optional):** Create a separate Discord channel for *all* server activity, including chat, commands, and logs. Ideal for moderation and debugging.\n*   **Easy Configuration:** Customize settings quickly and easily with a straightforward configuration schema.\n\n## Configuration Options\n\n*   `sendPlayerConnected`: (`true`/`false`, default: `true`) Enable player connect notifications.\n*   `sendPlayerDisconnected`: (`true`/`false`, default: `true`) Enable player disconnect notifications.\n*   `onlyGlobalChat`: (`true`/`false`, default: `true`) Restrict to global chat only.\n*   `filterCommands`: (`true`/`false`, default: `false`) Filter out in-game command messages.\n*   `filterSystemMessages`: (`true`/`false`, default: `false`) Filter out system messages.\n*   `useMonitoring`: (`true`/`false`, default: `false`) Enable a dedicated monitoring channel.\n*   `monitoringChannelId`: (string) Discord channel ID for monitoring (required if `useMonitoring` is enabled).\n\n## Hooks\n\n*   `PlayerDisconnected` / `PlayerConnected`: Handles player join/leave notifications.\n*   `DiscordToGame`: Relays messages from your Discord server to the game.\n*   `GameToDiscord`: Relays in-game chat messages to Discord, applying all configured filters.",
      "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)\"},\"filterCommands\":{\"title\":\"Filter commands\",\"type\":\"boolean\",\"default\":false,\"description\":\"Don't relay command messages (/command) to Discord\"},\"filterSystemMessages\":{\"title\":\"Filter system messages\",\"type\":\"boolean\",\"default\":false,\"description\":\"Don't relay system messages to Discord\"},\"useMonitoring\":{\"title\":\"Enable monitoring channel\",\"type\":\"boolean\",\"default\":false,\"description\":\"Send commands and system messages to a separate monitoring channel\"},\"monitoringChannelId\":{\"title\":\"Monitoring channel ID\",\"type\":\"string\",\"description\":\"Discord channel ID for monitoring messages (only used if monitoring is enabled)\"}},\"additionalProperties\":false}",
      "uiSchema": "{}",
      "commands": [],
      "hooks": [
        {
          "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"
        },
        {
          "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": "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        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';\n\nasync function main() {\n    const config = data.module.userConfig;\n\n    // Get message details\n    const sender = data.player ? data.player.name : 'Non-player';\n    const message = data.eventData.msg;\n    const isCommand = message.startsWith('/');\n\n    // Format message\n    const formattedMessage = `**${sender}**: ${message}`;\n\n    // Always send to monitoring channel if enabled\n    if (config.useMonitoring && config.monitoringChannelId) {\n        await takaro.discord.discordControllerSendMessage(config.monitoringChannelId, {\n            message: formattedMessage\n        });\n    }\n\n    // Apply filters for main channel\n    if (config.onlyGlobalChat && data.eventData.channel !== 'global') return;\n    if (isCommand && config.filterCommands) return;\n    if (sender === 'Non-player' && config.filterSystemMessages) return;\n\n    // Send to main channel after filters\n    const mainChannel = data.module.systemConfig.hooks['DiscordToGame'].discordChannelId;\n    await takaro.discord.discordControllerSendMessage(mainChannel, {\n        message: formattedMessage\n    });\n}\n\nawait main();"
        }
      ],
      "cronJobs": [],
      "functions": [],
      "permissions": []
    }
  ]
}