First plugin - partially working

I tried to create my own "info" bot with command /info based of some other plugins (ServerChat/SaveAnnouncer).
To try and learn more and have a greater feeling of ownership maybe. 

It should grab a couple of definitions from the config file but at the moment it is not doing so. Or, partially it is. 

It grabs the message color. Which is all. It does not print the ChatIcon nor Title. 
It creates and verifies the config - but seems to only grab some of the info (color/size). 

I was hoping somebody could point me in the right direction? Since its not giving any errors and is in some way working - I dont know what to look for. 

It sends the reply, and with color formatting (i added partially white color to verify its getting color).
https://i.imgur.com/o7uxIK4.jpg

using System;
using Newtonsoft.Json;
using System.Collections.Generic;
using Oxide.Core;

using System.Linq;
using System.Text;
using Oxide.Core.Libraries.Covalence;
using Oxide.Core.Plugins;

namespace Oxide.Plugins
{
    [Info("Infobot", "JE", "1.0.3")]
    [Description("Serves as Tier 0 self service information bot.")]
	
	
    public class Infobot : RustPlugin
    {
		
		#region Config
        Configuration config;

        class Configuration
        {
            [JsonProperty(PropertyName = "Icon (SteamID64)")]
            public ulong ChatIcon = 0;

            [JsonProperty(PropertyName = "Title")]
            public string Title = "Title";

            [JsonProperty(PropertyName = "Title Color")]
            public string TitleColor = "#deff00";

            [JsonProperty(PropertyName = "Title Size")]
            public int TitleSize = 15;

            [JsonProperty(PropertyName = "Message Color")]
            public string MessageColor = "#dfdfdf";

            [JsonProperty(PropertyName = "Message Size")]
            public int MessageSize = 15;
        }

        protected override void LoadConfig()
        {
            base.LoadConfig();
            try
            {
                config = Config.ReadObject<Configuration>();
                if (config == null) throw new Exception();
            }
            catch
            {
                Config.WriteObject(config, false, $"{Interface.Oxide.ConfigDirectory}/{Name}.jsonError");
                PrintError("The configuration file contains an error and has been replaced with a default config.\n" +
                           "The error configuration file was saved in the .jsonError extension");
                LoadDefaultConfig();
            }

            SaveConfig();
        }
		
        protected override void LoadDefaultConfig() => config = new Configuration();

        protected override void SaveConfig() => Config.WriteObject(config);
        #endregion
		

		
		
         [ChatCommand("info")]
         private object HelloCommand(BasePlayer player, string command)
         {
			string icon = $"{config.ChatIcon}";
			string title = $"<color={config.TitleColor}><size={config.TitleSize}>{config.Title}</size></color>\r\n";
            string msg = $"<color={config.MessageColor}><size={config.MessageSize}>This is a <color=#ffffff>test</size></color>";

			 
			SendReply(player, msg, title, icon);
			return true;
			  
			  
         }
    }
}
Avoid overriding config. Remove Config.WriteObject from LoadConfig at least, and SaveConfig too since it can override config that is invalid. Chat command should be like that afaik;
[ChatCommand("blah")]
private void BlahCommandExample(BasePlayer player, string command, string[] args)
hm, maybe SendReply function doesn't work correctly? check SmartChatBot, it adds prefix and etc manually
5b6ed4c9ac8e4.jpg misticos
Avoid overriding config. Remove Config.WriteObject from LoadConfig at least, and SaveConfig too since it can override config that is invalid. Chat command should be like that afaik;
[ChatCommand("blah")]
private void BlahCommandExample(BasePlayer player, string command, string[] args)
hm, maybe SendReply function doesn't work correctly? check SmartChatBot, it adds prefix and etc manually

Cheers, its much easier to follow the trail of logic when I get errors.. Its harder when I do not and plugin partially working. 

I did your suggestions, but It still only sends the message(test) with formatting. Title and Icon still ghost. 

Seems to me it cant grab the text from config file...which is strange since its grabbing hex colors. 

I removed Load default config and SaveConfig. 

I need to understand this before moving on. 



Merged post


Is this properly formatted to give out all the arguments? 

SendReply(player, msg, title, icon);

No, SendReply is working fine (despite RustPlugin helpers are being deprecated according to Wulf), he's just using it wrong, there are no place for "title" or "icon", it just accepts same args as string.Format()

protected void SendReply(BasePlayer player, string format, params object[] args)
{
      PrintToChat(player, format, args);
}


Merged post

IPlayer.Message(string message, string prefix, params object[] args)

Can help you with adding prefix to the message, but I think there is no helper method for chat icon atm



Merged post

If you want to add icon to the message, you'd have to do it manually
BasePlayer.SendConsoleCommand("chat.add", 0/* <- this is steamid for icon */, msg);​
5b6ed4c9ac8e4.jpg misticos
Avoid overriding config. Remove Config.WriteObject from LoadConfig at least, and SaveConfig too since it can override config that is invalid. Chat command should be like that afaik;
[ChatCommand("blah")]
private void BlahCommandExample(BasePlayer player, string command, string[] args)
hm, maybe SendReply function doesn't work correctly? check SmartChatBot, it adds prefix and etc manually

Neither return type or parameters of method matters, it depends on which info you'd like to get inside of it.
But making it object is not a good practice still I beleive

As I said, make sure you use a custom.method you declare yourself like in smart chat bot. Try to replace variables with hard coded constants, so u type them in manually

Merged post

This should help. If not, then no idea honestly, should work