Team chat showing up in Discord chat
Halsafe
Hello, after this new update the team chat is now showing up in the discord channel. Is there a perm to stop that or do I have to remove a perm?
nils
same here i fixed it allready if you open the file in a text editor you have to change 2 lines

on line 238 change this
 private void OnPlayerChat(ConsoleSystem.Arg arg)
        {
            if (_client == null) return;
            if(!Ready) return;
            var player = arg.Player();
	    var message = arg.GetString(1);
            if (player == null || message == null) return;
            if (permission.UserHasPermission(player.UserIDString, "rustcord.hidechat")) return;
            if (BetterChatMute?.Call("API_IsMuted", player.IPlayer) ?? false) return;
			if (Channel.Contains("0")){
            if(_settings.FilterWords != null && _settings.FilterWords.Count > 0) {
                for (int i = _settings.FilterWords.Count - 1; i >= 0; i--)
                {
                    while (message.Contains(" " + _settings.FilterWords[i] + " ") || message.Contains(_settings.FilterWords[i]))
                        message = message.Replace(_settings.FilterWords[i], _settings.FilteredWord ?? "");
                }
            }

            _settings.Channels.Where(x => x.perms.Contains("msg_chat")).ToList().ForEach(ch =>
            {
                GetChannel(_client, ch.Channelid, chan =>
                {
                    if (!(player != null && player.IsValid())) return;
                    chan.CreateMessage(_client, Translate("RUST_OnPlayerChat", new Dictionary {
                        { "playername", player.displayName },
                        { "message", message },
                        { "playersteamid", player.UserIDString }

                    }));
                });
            });
        }​

to this 

 private void OnPlayerChat(ConsoleSystem.Arg arg)
        {
            if (_client == null) return;
            if(!Ready) return;
            var player = arg.Player();
			var Channel = arg.GetString(0);
            var message = arg.GetString(1);
            if (player == null || message == null) return;
            if (permission.UserHasPermission(player.UserIDString, "rustcord.hidechat")) return;
            if (BetterChatMute?.Call("API_IsMuted", player.IPlayer) ?? false) return;
			if (Channel.Contains("0")){
            if(_settings.FilterWords != null && _settings.FilterWords.Count > 0) {
                for (int i = _settings.FilterWords.Count - 1; i >= 0; i--)
                {
                    while (message.Contains(" " + _settings.FilterWords[i] + " ") || message.Contains(_settings.FilterWords[i]))
                        message = message.Replace(_settings.FilterWords[i], _settings.FilteredWord ?? "");
                }
            }

            _settings.Channels.Where(x => x.perms.Contains("msg_chat")).ToList().ForEach(ch =>
            {
                GetChannel(_client, ch.Channelid, chan =>
                {
                    if (!(player != null && player.IsValid())) return;
                    chan.CreateMessage(_client, Translate("RUST_OnPlayerChat", new Dictionary {
                        { "playername", player.displayName },
                        { "message", message },
                        { "playersteamid", player.UserIDString }

                    }));
                });
            });
			};
        }

I now only display channel 0 (global chat) in discord. The rest still works as intended so all the settings for hiding someone in the chat.
Halsafe
Original Poster
Awesome, thanks!
zinet2k
Is there any option where discord chatlogs doesnt fetch "Team" chats? rather only Global chat.
GenSriracha
nils
same here i fixed it allready if you open the file in a text editor you have to change 2 lines

on line 238 change this
 private void OnPlayerChat(ConsoleSystem.Arg arg)
        {
            if (_client == null) return;
            if(!Ready) return;
            var player = arg.Player();
	    var message = arg.GetString(1);
            if (player == null || message == null) return;
            if (permission.UserHasPermission(player.UserIDString, "rustcord.hidechat")) return;
            if (BetterChatMute?.Call("API_IsMuted", player.IPlayer) ?? false) return;
			if (Channel.Contains("0")){
            if(_settings.FilterWords != null && _settings.FilterWords.Count > 0) {
                for (int i = _settings.FilterWords.Count - 1; i >= 0; i--)
                {
                    while (message.Contains(" " + _settings.FilterWords[i] + " ") || message.Contains(_settings.FilterWords[i]))
                        message = message.Replace(_settings.FilterWords[i], _settings.FilteredWord ?? "");
                }
            }

            _settings.Channels.Where(x => x.perms.Contains("msg_chat")).ToList().ForEach(ch =>
            {
                GetChannel(_client, ch.Channelid, chan =>
                {
                    if (!(player != null && player.IsValid())) return;
                    chan.CreateMessage(_client, Translate("RUST_OnPlayerChat", new Dictionary {
                        { "playername", player.displayName },
                        { "message", message },
                        { "playersteamid", player.UserIDString }

                    }));
                });
            });
        }​

to this 

 private void OnPlayerChat(ConsoleSystem.Arg arg)
        {
            if (_client == null) return;
            if(!Ready) return;
            var player = arg.Player();
			var Channel = arg.GetString(0);
            var message = arg.GetString(1);
            if (player == null || message == null) return;
            if (permission.UserHasPermission(player.UserIDString, "rustcord.hidechat")) return;
            if (BetterChatMute?.Call("API_IsMuted", player.IPlayer) ?? false) return;
			if (Channel.Contains("0")){
            if(_settings.FilterWords != null && _settings.FilterWords.Count > 0) {
                for (int i = _settings.FilterWords.Count - 1; i >= 0; i--)
                {
                    while (message.Contains(" " + _settings.FilterWords[i] + " ") || message.Contains(_settings.FilterWords[i]))
                        message = message.Replace(_settings.FilterWords[i], _settings.FilteredWord ?? "");
                }
            }

            _settings.Channels.Where(x => x.perms.Contains("msg_chat")).ToList().ForEach(ch =>
            {
                GetChannel(_client, ch.Channelid, chan =>
                {
                    if (!(player != null && player.IsValid())) return;
                    chan.CreateMessage(_client, Translate("RUST_OnPlayerChat", new Dictionary {
                        { "playername", player.displayName },
                        { "message", message },
                        { "playersteamid", player.UserIDString }

                    }));
                });
            });
			};
        }

I now only display channel 0 (global chat) in discord. The rest still works as intended so all the settings for hiding someone in the chat.

I'm trying to add this but I'm just getting an error

| Unable to load Rustcord. Rustcord.cs(265,83): error CS0305: Using the generic type `System.Collections.Generic.Dictionary<TKey,TValue>' requires `2' type argument(s)

ziga

idk doesnt work for me aswell

Halsafe
Original Poster
ziga

idk doesnt work for me aswell

Same here, it just broke again. Need a fix ASAP

GenSriracha
I found saving the file a couple of times some how worked lol
Teal

I spent a little time trying to get this solution to above to work, and nah, no matter how many times you save the file it aint going to work. heres what works for me, and its less modification than the above.

Old Code Line:238

        private void OnPlayerChat(ConsoleSystem.Arg arg)
        {
            if (_client == null) return;
            if(!Ready) return;
            var player = arg.Player();
            var message = arg.GetString(1);
            if (player == null || message == null) return;
            if (permission.UserHasPermission(player.UserIDString, "rustcord.hidechat")) return;
            if (BetterChatMute?.Call<bool>("API_IsMuted", player.IPlayer) ?? false) return;
            if(_settings.FilterWords != null && _settings.FilterWords.Count > 0) {
                for (int i = _settings.FilterWords.Count - 1; i >= 0; i--)
                {
                    while (message.Contains(" " + _settings.FilterWords[i] + " ") || message.Contains(_settings.FilterWords[i]))
                        message = message.Replace(_settings.FilterWords[i], _settings.FilteredWord ?? "");
                }
            }

            _settings.Channels.Where(x => x.perms.Contains("msg_chat")).ToList().ForEach(ch =>
            {
                GetChannel(_client, ch.Channelid, chan =>
                {
                    if (!(player != null && player.IsValid())) return;
                    chan.CreateMessage(_client, Translate("RUST_OnPlayerChat", new Dictionary<string, string> {
                        { "playername", player.displayName },
                        { "message", message },
                        { "playersteamid", player.UserIDString }

                    }));
                });
            });
        }

 

 

New Code

        private void OnPlayerChat(ConsoleSystem.Arg arg)
       {
           if (_client == null) return;
           if(!Ready) return;
           var player = arg.Player();
           var Channel = arg.GetString(0);
           var message = arg.GetString(1);
           if (player == null || message == null) return;
           if (permission.UserHasPermission(player.UserIDString, "rustcord.hidechat")) return;
           if (BetterChatMute?.Call<bool>("API_IsMuted", player.IPlayer) ?? false) return;
           if (Channel.Contains("1")) return;
           if(_settings.FilterWords != null && _settings.FilterWords.Count > 0) {
               for (int i = _settings.FilterWords.Count - 1; i >= 0; i--)
               {
                   while (message.Contains(" " + _settings.FilterWords[i] + " ") || message.Contains(_settings.FilterWords[i]))
                       message = message.Replace(_settings.FilterWords[i], _settings.FilteredWord ?? "");
               }
           }

           _settings.Channels.Where(x => x.perms.Contains("msg_chat")).ToList().ForEach(ch =>
           {
               GetChannel(_client, ch.Channelid, chan =>
               {
                   if (!(player != null && player.IsValid())) return;
                   chan.CreateMessage(_client, Translate("RUST_OnPlayerChat", new Dictionary<string, string> {
                       { "playername", player.displayName },
                       { "message", message },
                       { "playersteamid", player.UserIDString }

                   }));
               });
           });
        
       }