Coder Social home page Coder Social logo

imi-tat0r / cs2-discordchatsync Goto Github PK

View Code? Open in Web Editor NEW
15.0 1.0 0.0 96 KB

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

License: MIT License

C# 100.00%
counter-strike counter-strike-2 counterstrikesharp cs2 discord sync addon cssharp extension metamod module plugin cs2-plugin

cs2-discordchatsync's Introduction

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

cs2-discordchatsync's People

Contributors

imi-tat0r avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

cs2-discordchatsync's Issues

[BUG] Crash

Server Crashes when send emoji on chat on discord.

Will be cool a support for the main emojis :)
image

[Feature] Team Name

Hello, actualy, Team name is
Team team.t.short - team.t.long

because he take Teamname from Players
is possible to have a variable for take Team Name from team not players ?

.NET8 Upgrade

Would be Awesome to see this Update happen, since i enjoy having this plugin my Server to check on the Phone whats up with Servers.
Thanks of course for ure Work.
Cheers

[CONFLICT]

The plugin CS2-tags have a conflict with this plugin in chat.

I tested with cs2-tags and not work, but without cs2 tags works

[Suggestion] Server crash alerts

Hey!

It would be cool if you could provide a sudden server disconnect interrupt message some how. I'm not sure if there's an exact srcds line you could look for, or simply if the DiscordChatSync loses a connection with the server itself.

Curious of your thoughts! It would help me personally, and I'm sure others would enjoy this as well!

[SUUGESTIONS] a lot suggestions

  • Add prefix to cs2 chat when sended messages on discord to cs2
    ex:
    [From discord] aka: im here from discord

Support for colors too

  • Change the lang for the System messaged sended to discord and change what messages will appear on discord

  • Suggestion to add: Prefix for sended message cs2 to discord like:

PrefixDiscord "[Server] {steamid64} {time} aka: Hey"

  • Suggestion to add to a admin only channel, so im admin and when i send message on a channel discord that im admin, will send a message as admin on cs2

[Suggestion] Administration via Discord

Hey!

Thanks for this plugin. I am wondering if you could make it possible to run commands to the server from the discord channel. Commands like !rcon exec blah or !map aren't recognized due to current limitations, and obviously could add a lot of usability to this already nice plugin.

Thoughts are appreciated!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.