chatbridge

  • community
  • integration
  • by limon
  • Takaro main
  • all
Version
View export JSON

Limon_chatbridge: Discord Chat Integration for Your Game Server

This module bridges your game server's chat and a Discord channel, enabling two-way communication with powerful, customizable filtering options.

Key Features

  • Two-Way Chat Relay: Forward messages between your game and Discord in real-time. Improve player interaction and build a stronger community.
  • Player Connection/Disconnection Notifications: Optionally send automated Discord messages when players join or leave your server.
  • Advanced Filtering Options:
    • Global Chat Only: Restrict messages to your game's global chat channel, excluding team chat and private messages.
    • Command Filtering: Prevent in-game command messages (e.g., /ban) from cluttering your Discord.
    • System Message Filtering: Keep your Discord clean by blocking system (non-player) messages.
  • Dedicated Monitoring Channel (Optional): Create a separate Discord channel for all server activity, including chat, commands, and logs. Ideal for moderation and debugging.
  • Easy Configuration: Customize settings quickly and easily with a straightforward configuration schema.

Configuration Options

  • sendPlayerConnected: (true/false, default: true) Enable player connect notifications.
  • sendPlayerDisconnected: (true/false, default: true) Enable player disconnect notifications.
  • onlyGlobalChat: (true/false, default: true) Restrict to global chat only.
  • filterCommands: (true/false, default: false) Filter out in-game command messages.
  • filterSystemMessages: (true/false, default: false) Filter out system messages.
  • useMonitoring: (true/false, default: false) Enable a dedicated monitoring channel.
  • monitoringChannelId: (string) Discord channel ID for monitoring (required if useMonitoring is enabled).

Hooks

  • PlayerDisconnected / PlayerConnected: Handles player join/leave notifications.
  • DiscordToGame: Relays messages from your Discord server to the game.
  • GameToDiscord: Relays in-game chat messages to Discord, applying all configured filters.

Configuration 7

Settings you fill in when installing the module on a server.

SettingTypeDefaultDescription
sendPlayerConnected Send player connected boolean true Send a message when a player connects.
sendPlayerDisconnected Send player disconnected boolean true Send a message when a player disconnects.
onlyGlobalChat Only global chat boolean true Only relay messages from global chat (no team chat or private messages)
filterCommands Filter commands boolean false Don't relay command messages (/command) to Discord
filterSystemMessages Filter system messages boolean false Don't relay system messages to Discord
useMonitoring Enable monitoring channel boolean false Send commands and system messages to a separate monitoring channel
monitoringChannelId Monitoring channel ID string Discord channel ID for monitoring messages (only used if monitoring is enabled)
Raw config schema
{
  "$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
}
Raw UI schema
{}

Hooks 4

Code that runs in reaction to a game or Takaro event.

  • PlayerDisconnected

    Hook for player-disconnected events

    Hook source
    import { takaro, data } from '@takaro/helpers';
    async function main() {
        const discordChannel = data.module.systemConfig.hooks['DiscordToGame'].discordChannelId;
        await takaro.discord.discordControllerSendMessage(discordChannel, {
            message: `[👋 Disconnected]: ${data.player.name}`,
        });
    }
    await main();
    //# sourceMappingURL=PlayerDisconnected.js.map
  • PlayerConnected

    Hook for player-connected events

    Hook source
    import { takaro, data } from '@takaro/helpers';
    async function main() {
        const discordChannel = data.module.systemConfig.hooks['DiscordToGame'].discordChannelId;
        await takaro.discord.discordControllerSendMessage(discordChannel, {
            message: `[⚡ Connected]: ${data.player.name}`,
        });
    }
    await main();
    //# sourceMappingURL=PlayerConnected.js.map
  • DiscordToGame

    Hook for discord-message events

    Hook source
    import { takaro, data } from '@takaro/helpers';
    async function main() {
        try {
            if (data.eventData.author.isBot)
                return;
            await takaro.gameserver.gameServerControllerSendMessage(data.gameServerId, {
                message: `[D] ${data.eventData.author.displayName}:  ${data.eventData.msg}`,
            });
        }
        catch (error) {
            console.error(error);
            await takaro.discordControllerSendMessage(data.discordChannelId, {
                message: 'Failed to forward your message to the game. Please try again later.',
            });
        }
    }
    await main();
    //# sourceMappingURL=DiscordToGame.js.map
  • GameToDiscord

    Hook for chat-message events

    Hook source
    import { takaro, data } from '@takaro/helpers';
    
    async function main() {
        const config = data.module.userConfig;
    
        // Get message details
        const sender = data.player ? data.player.name : 'Non-player';
        const message = data.eventData.msg;
        const isCommand = message.startsWith('/');
    
        // Format message
        const formattedMessage = `**${sender}**: ${message}`;
    
        // Always send to monitoring channel if enabled
        if (config.useMonitoring && config.monitoringChannelId) {
            await takaro.discord.discordControllerSendMessage(config.monitoringChannelId, {
                message: formattedMessage
            });
        }
    
        // Apply filters for main channel
        if (config.onlyGlobalChat && data.eventData.channel !== 'global') return;
        if (isCommand && config.filterCommands) return;
        if (sender === 'Non-player' && config.filterSystemMessages) return;
    
        // Send to main channel after filters
        const mainChannel = data.module.systemConfig.hooks['DiscordToGame'].discordChannelId;
        await takaro.discord.discordControllerSendMessage(mainChannel, {
            message: formattedMessage
        });
    }
    
    await main();