Can't get chat to work right with another plugin
I made a plugin for my Rust server and am having issues. I haven't been coding C# for too long, maybe a year or two but I only make small private plugins for myself.

If my plugin is loaded, and a user is muted with BetterChat Mute, something allows them to still type. If my plugin is unloaded, they are blocked from typing because of mute. If the plugin isn't reloaded after the first time installing it, user chat prints twice. Any help appreciated.
using ConVar;
using System.Collections.Generic;
namespace Oxide.Plugins
{
    [Info("CustomCommands", "Ryz0r", "1.2")]
    [Description("Custom Commands Plugin made by Ryz0r")]

    class CustomCommands : RustPlugin
    {
        object OnPlayerChat(BasePlayer player, string message, Chat.ChatChannel channel)
        {
			var steamID = "76561198907351815";
			var serverName = "RustOps";
			var count = 0;
			
			foreach (BasePlayer playerz in BasePlayer.activePlayerList)
				{
					if (playerz.IsAdmin)
						{
							count ++;
								}
						}


			var cPlayers = ConVar.Admin.ServerInfo().Players;
            var mPlayers = ConVar.Admin.ServerInfo().MaxPlayers;
            var jPlayers = ConVar.Admin.ServerInfo().Joining;
            var qPlayers = ConVar.Admin.ServerInfo().Queued;	
		
		
            if (player == null || string.IsNullOrEmpty(message) || channel != Chat.ChatChannel.Global) {
                return null;
				
			} else if (message.Contains("!pop") || message.Contains("!POP") || message.Contains("!players") || message.Contains("online")) {
				
				rust.SendChatMessage(player, $"[{serverName}]", $"<color=#ff0000>There is {count} admin(s) online.</color> <color=#505050>There are currently <color=orange>{cPlayers}/{mPlayers} ({jPlayers} joining) </color> players online with a queue of <color=orange>{qPlayers}</color> players!</color>", steamID);
				
			} else if (message.Contains("!discord")) {
				
				rust.SendChatMessage(player, $"[{serverName}]", $"<color=#505050>Hey, <color=orange>{player.displayName}</color>! You can join the {serverName} Discord to get support from a staff member or view more info on the server. Join:<color=orange> discord link removed </color></color>", steamID);
				
			} else if (message.Contains("!admin")) {
				rust.SendChatMessage(player, $"[{serverName}]", $"<color=#505050>Hey, <color=orange>{player.displayName}</color>! If an admin doesn't respond, please join the Discord and view #support! Join:<color=orange> discord link removed </color></color>", steamID);
			}
			
			return "Operation completed succesfully.";
			
        }
	}
}

​
Your plugin will not work with other chat plugins as you do not have any compatibility with them; they'd be handling the chat with the same hook. Also, for the return, I'd suggest using true to cancel the chat, not "Operation completed successfully." as you'll likely see hook conflict warnings with that.

I would suggest using normal chat commands as well, intercepting the chat to provide commands is unnecessary.
Thanks for the reply, Wulf.

This is what we have been using since RustOps was launched years ago so everybody is used to typing !command here for our commands. It was working fine up until the update yesterday even without compatibility with other chat plugins it wasn't giving any issues.

Any idea why it would have made such a drastic change? Because now like I said messages are typing twice, and muting isn't working.
If you are running any other chat plugin, they can send their own chat and are. Likely that something changed with your setup with one of the other chat plugins you are using.
Thanks for the advice. I fixed it. Now using Better Chat entirely.


EDIT: Changing code again
Aside from intercepting chat to have ! for commands... :P

I'm not sure where "playerObj" and "messageObj" are coming from, but they do not appear to exist in your above code. 

You could use a switch/case setup instead of if/else if stack; and use .ToLower() when handling the message check instead of multiple case checks.

I'd also switch to the universal API (Covalence) instead of mixing or using game-specific code, as there's reason to be using older methods and such.
I was basing it off of another plugin I had saw that handled chat and Discord, but I'm going to go back and recode this.