Discord/whitelist integrationSolved
quietconundrum
I'm currently using Whitelist and Rustcord plugins and I had attempted to integrate a hook into Rustcord that would capture the CanUserLogin denials that Whitelist outputs to the console and relay them to the admin channel of my Discord.

For anyone unfamiliar with said outputs: when a player attempts to connect to the server and is not whitelisted, they get a customizable rejection message in their in-game server browser... and in the server console, you see output similar to this ([IP]:[Port]/[SteamID64]/[Player] [Message]):

123.456.789.10:12345/12345678910111213/PlayerName Rejecting connection - Sorry, only members are allowed inside.​


My attempt at said hook:

[HookMethod("OnUserApprove")]
private object OnUserApprove(Network.Connection connection)
{
	    var _player_id = connection.userid.ToString();
	    var _player_name = connection.username.ToString();
            var _player_ip = Regex.Replace(connection.ipaddress, @":{1}[0-9]{1}\d*", "");

            // Call out and see if we should reject
            object canLogin = Interface.Call("CanClientLogin", connection) ?? Interface.Call("CanUserLogin", connection.username, _player_id, _player_ip);
            if (canLogin != null && (!(canLogin is bool) || !(bool)canLogin))
            {
                // Connection Rejected
                _settings.Channels.Where(x => x.perms.Contains("msg_joinlog")).ToList().ForEach(ch => {
					Channel.GetChannel(_client, ch.Channelid, chan =>
					{
						// Admin
						chan.CreateMessage(_client, Translate("RUST_OnPlayerRejectedAdminLog", new Dictionary<string, string>
						{
							{ "playername", _player_name },
							{ "playerip",  _player_ip },
							{ "playersteamid", _player_id },
							{ "playermessage", canLogin.ToString() }
						}));
					});
				});
            }
	    return null;
}

Of course, the channel perms and language template are properly defined above this code.

I had a server member (who I temporarily removed from the whitelist) test this with me and it didn't seem to fire. The rejections appeared in my server console as usual, but I got no errors from Rustcord and no message relay to the target channel.

I need more seasoned expertise to help get this integration working, please. Thanks for your time.

quietconundrum
Original Poster
Disregard. I got this working on my own. Thanks, @Wulf, for suggesting I simply integrate one plugin's functionality into another... that, plus a different function hook was the trick.