Skip to content

johnqherman/SourceCord

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SourceCord

Build Release License Latest Release

Overview

A SourceMod plugin that syncs chat between your Source Engine server and Discord.

Players can talk with Discord users directly from in-game, while Discord messages appear in chat with nicknames and role colors.

Side by Side
Images courtesy of boba

Features

  • Two-way chat sync: Game ↔ Discord messages in real time
  • Mentions: Handles user, role, and channel mentions seamlessly
  • Steam profile integration: Player avatars and configurable Steam ID formats
  • Server event logs: Join/leave notifications for players
  • Caching system: Fast lookups for avatars, nicknames, role colors, etc.

Game Compatibility

Game Status Notes
Team Fortress 2 ✅ Tested Designed for TF2, works flawlessly
Half-Life 2: Deathmatch ✅ Tested Includes any mod based on Source SDK 2013
Counter-Strike: Source ✅ Supported 64-bit only
Left 4 Dead 2 ✅ Supported 64-bit only
Insurgency ✅ Supported 64-bit only
Counter-Strike: Global Offensive ⚠️ Legacy Deprecated; last CS:GO server builds only
Day of Defeat: Source ❌ Unsupported Incompatible with SourceMod 1.12+
Garry's Mod ❌ Incompatible Not officially supported

SourceCord should work with any Source Engine game that supports SourceMod 1.12+.
If you encounter issues, please file a bug report.

Requirements

  • SourceMod: Version 1.12 or higher
  • REST in Pawn: For HTTP requests to Discord API
  • Discord Bot: Bot token with appropriate permissions
  • Steam API Key: For fetching player profile information

Installation

  1. Install the REST in Pawn extension on your server
  2. Download the latest sourcecord.smx from releases
  3. Place sourcecord.smx in addons/sourcemod/plugins/
  4. Load the plugin with sm plugins load sourcecord (it will auto-create both config files)
  5. Edit cfg/sourcemod/sourcecord.cfg to set your preferred settings
  6. Edit addons/sourcemod/configs/sourcecord.cfg to add your credentials
  7. Restart the plugin with sm plugins reload sourcecord

Configuration

1. Settings

On first load, the plugin generates cfg/sourcemod/sourcecord.cfg with default settings.

Edit this file with your preferred settings:

sc_interval "1.0"              // Check Discord messages every x second(s)
sc_log_connections "1"         // Log player connections (0 = off, 1 = basic, 2 = with IP)
sc_use_role_colors "1"         // Show Discord role colors in-game? (enabled by default)
sc_use_nicknames "1"           // Use Discord server nicknames? (enabled by default)
sc_show_steam_id "1"           // Show Steam ID format (0 = off, 1 = steamID3, 2 = steamID)
sc_show_discord_prefix "1"     // Show [Discord] prefix in chat messages? (enabled by default)
sc_discord_color "5865F2"      // Hex color for Discord usernames in game chat (blurple by default)

2. Credentials File

The plugin will also generate addons/sourcemod/configs/sourcecord.cfg to store your credentials.

"SourceCord"
{
    "Discord"
    {
        "bot_token"     ""  // Discord Bot token
        "channel_id"    ""  // Discord channel ID
        "guild_id"      ""  // Discord guild/server ID
        "webhook_url"   ""  // Discord Webhook URL
    }

    "Steam"
    {
        "api_key"       ""  // Steam API key
    }
}

Discord Setup

Step 1: Create Bot and Get Token

  1. Go to the Discord Developer Portal
  2. Create a new application and bot user
  3. Copy the bot token and add it to your configs/sourcecord.cfg file as bot_token

Step 2: Enable Required Bot Intents

  1. In the Discord Developer Portal, go to your bot's Bot settings page
  2. Scroll down to Privileged Gateway Intents
  3. Enable these intents:
  • Server Members Intent: Required for fetching member nicknames and role information.
  • Message Content Intent: Required to read the actual content of Discord messages.
  1. Save changes.

Step 3: Invite Bot to Your Server

Required Permissions:

  • View Channels: Needed to see the configured channel and resolve mentions
  • Read Message History: Needed to fetch/catch up on messages

Bot Invitation URL:

Use this URL to invite your bot to your server with the required permissions (replace <YOUR_BOT_CLIENT_ID>):

https://discord.com/api/oauth2/authorize?client_id=<YOUR_BOT_CLIENT_ID>&permissions=66560&scope=bot

⚠️ This only sets permissions - you also need to enable the required intents in Step 2.

Step 4: Set up Webhook

  1. In your Discord channel, go to Edit Channel → Integrations → Webhooks
  2. Create a new webhook (optionally set a default avatar)
  3. Copy the webhook URL and add it to configs/sourcecord.cfg as webhook_url

Step 5: Get Discord IDs

  • Developer Mode: User Settings → Advanced → Developer Mode → Enable
  • Channel ID: Right-click channel → Copy Channel ID (add to configs/sourcecord.cfg as channel_id)
  • Guild ID: Right-click server name → Copy Server ID (add to configs/sourcecord.cfg as guild_id)

Steam API Key

  1. Generate a Steam API key from the Steam Web API
  2. Add it to configs/sourcecord.cfg as api_key

Customization Options

Edit these settings in cfg/sourcemod/sourcecord.cfg to customize SourceCord to your liking.

Steam ID Display

Control Steam ID format in both Discord messages and connection logs:

  • Disabled (sc_show_steam_id 0):

  • SteamID3 Format (sc_show_steam_id 1):

  • SteamID Format (sc_show_steam_id 2):

⚠️Note: Steam IDs will appear in chat messages and connection messages when enabled.

Connection Logging

Control what information appears in connect/disconnect messages:

  • Disabled (sc_log_connections 0):

    • No connect/disconnect messages sent to Discord
  • Basic Logging (sc_log_connections 1):

  • IP Logging (sc_log_connections 2):

Discord Prefix

Control whether the [Discord] prefix appears in game chat:

  • Enabled (sc_show_discord_prefix 1):

  • Disabled (sc_show_discord_prefix 0):

Discord Username Color

Customize the default color of Discord usernames in game chat:

  • Default: (sc_discord_color "5865F2"):

  • Custom: (sc_discord_color "EF0988"):

⚠️Note: When Discord role colors are enabled (sc_use_role_colors 1), user role colors take precedence over sc_discord_color.

Building from Source

Prerequisites

  • SourceMod compiler (spcomp)
  • REST in Pawn includes

Compilation

# Clone repository
git clone https://github.com/johnqherman/SourceCord.git
cd SourceCord

# Copy files to SourceMod's scripting directory
cp sourcecord.sp /path/to/addons/sourcemod/scripting/
cp -r sourcecord/ /path/to/addons/sourcemod/scripting/

# Compile the plugin
cd /path/to/addons/sourcemod/scripting/
spcomp sourcecord.sp

About

Discord chat integration for Source Engine via SourceMod

Topics

Resources

License

Stars

Watchers

Forks