Skip to content

A plugin for Counter-Strike 2 that syncs chat between the game and a Discord channel.

License

Notifications You must be signed in to change notification settings

imi-tat0r/CS2-DiscordChatSync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Copyright ev0lve Digital GitHub License Issues Downloads Stars

CS2 Discord Chat Sync (1.1.1)

image

About

CS2 Discord Chat Sync is a plugin for Counter-Strike 2 that syncs chat between the game and a Discord channel. It features vast customization options for the message formatting and the Discord embeds. It also supports syncing team chat and chat from additional channels.

Features

  • Syncs chat between the game and a Discord channel
  • Syncs team chat (optional)
  • Syncs chat from additional channels (optional) - useful for news and announcements
  • Ignores chat and silent triggers from core config (optional)
  • Customizable Discord template for chat messages
  • Customizable message template for Discord messages
  • SyncPrefix to only sync messages with a certain prefix
  • Send RCON commands from Discord
  • Receive system messages in a channel (player join/leave, map change)
  • Reload config without restarting the server css_reload_cfg

Dependencies

Metamod:Source (2.x)
CounterStrikeSharp(v166)

Installation

  1. Install Metamod:Source and CounterStrikeSharp
  2. Place the addons folder in your servers game/csgo/ directory
    extract
  3. Create a Discord bot and invite it to your server
    3.1. Create a Discord bot
    3.2. Invite the bot to your server
    3.3. The Discord bot requires the following Privileged Gateway Intent:
    perms
  4. Add your Discord bot token and channel id to the config file
    4.1. Located at addons/counterstrikesharp/configs/plugins/DiscordChat/DiscordChat.json
  5. Restart your server

Message formatting

1. Discord => CS2

The following placeholders can be used in the ServerOutputFormat to dynamically display certain information about the Discord message or user.

1.1. Message Information

  • {Channel} - The Discord channel name
  • {Username} - The player's name
  • {UsernameStyled} - The player's name styled with their Discord role color

1.2. Time and Date

  • {Time} - The current time according to TimeFormat
  • {Date} - The current date according to DateFormat
  • More Information

1.3. Colors

  • You can use the following colors:{Default}, {White}, {DarkRed}, {Green}, {LightYellow}, {LightBlue}, {Olive}, {Lime}, {Red}, {LightPurple}, {Purple}, {Grey}, {Yellow}, {Gold}, {Silver}, {Blue}, {DarkBlue}, {BlueGrey}, {Magenta}, {LightRed}, {Orange}

    Example: {Green}some {Blue}colored {Red}text{Default} some default text

2. CS2 => Discord

The following placeholders can be used in the DiscordEmbedFormat and the DiscordEmbedFields to dynamically display certain information about the server or the player.

2.1. Player

  • {Player.Name} - The player's name
  • {Player.SteamID} - The player's SteamID
  • {Player.Team} - The player's short team name
  • {Player.TeamName} - The player's full team name
  • {Player.TeamNum} - The player's team number

2.2. Server

  • {Server.Name} - The server's name
  • {Server.MapName} - The server's map name
  • {Server.CurPlayers} - The server's current player count
  • {Server.MaxPlayers} - The server's maximum player count

2.3. Chat

  • {Chat.Message} - The chat message
  • {Chat.Team} - The receiving team of the chat message (All, T, CT, Spec)

2.4. Time and Date

  • {Time} - The current time according to TimeFormat
  • {Date} - The current date according to DateFormat
  • More Information

Config

{
   // your discord bot token
   "DiscordToken": "",
   // the message to display as the bot's status
   "DiscordStatusMessage": "discord.game_text",
   
   // the channel id to sync from and to
   "SyncChannelId": 0,
   // if false, team chat will not be synced
   "SyncTeamChat": false,
   // if false, console messages will not be synced (rcon say)
   "SyncConsoleSay": false,
   
   // the channel id to send system messages to (like player join/leave, map change)
   "SystemChannelId": 0,
   
   // the channel id to receive rcon commands from
   "RconChannelId": 0,
   // the message prefix for rcon commands (empty for all messages)
   "RconMessagePrefix": "!rcon",
   
   // additional channels to read from (for news and announcements)
   "AdditionalReadChannelIds": [],
   
   // if true, chat and silent triggers from the core config will be ignored
   "IgnoreChatTriggers": true,
   
   // options for output formatting
   "ChatFormatOptions": {
      // time   date format 
      "TimeFormat": "HH:mm:ss",
      "DateFormat": "dd.MM.yyyy",
      
      // format string for the chat output of discord messages
      "ServerOutputFormat": "[From Discord #{Channel}] {UsernameStyled} - {Green}{Date} {Blue}{Time}{Default}: {Message}",
      
      // prefix for messages that should be synced (empty for all messages)
      "SyncPrefix": "",
      
      // dictionary of fields for the discord embed
      // you can use all chat placeholders
      "DiscordEmbedFields": {
         "Server": "{Server.Name}",
         "Map": "{Server.MapName}",
         "Players": "{Server.CurPlayers}/{Server.MaxPlayers}",
         ":ballot_box_with_check: Player": "[{Player.Name} ({Player.SteamID})](https://steamcommunity.com/profiles/{Player.SteamID})",
         "Team": "{Player.TeamName} - {Player.Team} - Num: {Player.TeamNum}",
         "Message": "[{Chat.Team}] - {Chat.Message}",
         "Time": "{Time}",
         "Date": "{Date}"
      },
      
      // dictionary of general embed settings
      // you can set the author, avatar (requires author), title, thumbnail, footer and color
      // you can use all chat placeholders
      "DiscordEmbedFormat": {
         "Author": "{Server.Name}", // author of the embed (optional)
         "AvatarUrl": "", // url to the author's avatar (optional) - requires author
         "Title": "Message from {Player.Name}",
         "ThumbnailUrl": "", // url to the thumbnail (optional)
         "Footer": "https://github.com/imi-tat0r/CS2-DiscordChatSync",
         "FooterIconUrl": "", // url to the footer icon (optional)
         
         // hex color code #RRGGBB or "{TeamColor}" for the player's team color
         "Color": "{TeamColor}"
      },
      
      // dictionary of system messages
      // you can use all chat placeholders
      // leave empty or remove to disable a message
      "SystemMessages": {
         "PlayerConnect": "{Player.Name} joined the server",
         "PlayerDisconnect": "{Player.Name} left the server",
         "MapChange": "Changed map to {Server.MapName}"
      }
   },
   
   "ConfigVersion": 3 // do not change
}

Credits