Adding a new chat command to a pluggin

Hello, I would like to know if it is possible to add a new word to use the pluggin, currently it works with time and I would like to use it with another language, "hora".
I am using the pluggin from: SIMPLE TIME

The code cs:

using Newtonsoft.Json;
using Oxide.Core.Plugins;
using Oxide.Core;
using System;
using System.Text;
using System.Collections.Generic;
using System.Globalization;
using UnityEngine;

namespace Oxide.Plugins
{
    [Info("Simple Time", "MadKingCraig", "1.1.2")]
    [Description("Provides a chat command for the current game time")]
    public class SimpleTime : RustPlugin
    {
        private bool _initialized;
        private int _componentSearchAttempts;

        private const string CanUsePermission = "simpletime.use";

        #region Oxide Hooks
        private void Init()
        {
            permission.RegisterPermission(CanUsePermission, this);
        }

        private void Loaded()
        {
            _initialized = false;
        }

        private void OnServerInitialized()
        {
            if (TOD_Sky.Instance == null)
            {
                _componentSearchAttempts++;
                if (_componentSearchAttempts < 10)
                    timer.Once(1, OnServerInitialized);
                else
                    PrintWarning("Could not find required component after 10 attempts. Plugin disabled");
                return;
            }
            if (TOD_Sky.Instance.Components.Time == null)
            {
                PrintWarning("Could not fetch time component. Plugin disabled");
                return;
            }

            _initialized = true;
        }

        protected override void LoadDefaultMessages()
        {
            lang.RegisterMessages(new Dictionary<string, string>
            {
                ["Time"] = "Current Time: {0}",
                ["NoPermission"] = "You do not have permission to use this command."
            }, this);
        }
        #endregion

        #region Hooks
        [HookMethod("GetSimpleTime")]
        public string GetSimpleTime()
        {
            return TOD_Sky.Instance.Cycle.DateTime.ToString("HH:mm");
        }
        #endregion

        #region Commands
        [ChatCommand("hora")]
		private void TimeCommand(BasePlayer player, string command, string[] args)
		{
            if (!_initialized)
                return;

            string PlayerID = player.UserIDString;

            if (!permission.UserHasPermission(PlayerID, CanUsePermission))
            {
                SendReply(player, lang.GetMessage("NoPermission", this, PlayerID));
                return;
            }

            string currentTime = TOD_Sky.Instance.Cycle.DateTime.ToString("HH:mm");
            SendReply(player, string.Format(lang.GetMessage("Time", this, PlayerID), currentTime));
        }
        #endregion
    }
}
​

Your code is good. I don't understand what you want to achieve.

oESHrLEd4Ji1r5d.jpg ArtiIOMI

Your code is good. I don't understand what you want to achieve.

It works with the /Time command but I also want to use one more /time command
I don't know how to make them both work

Asintomatico

It works with the /Time command but I also want to use one more /time command
I don't know how to make them both work

If you want both commands then you'd just have to repeat the same chat command block, one being "time" other being "hora". For the second one you pasted you'll have to rename the function as well. They both can't be: "private void TimeCommand" so make the other one something like private void TimeCommand2 or HoraCommand.

For example:

#region Commands
        [ChatCommand("hora")]
		private void HoraCommand(BasePlayer player, string command, string[] args)
		{
            if (!_initialized)
                return;

            string PlayerID = player.UserIDString;

            if (!permission.UserHasPermission(PlayerID, CanUsePermission))
            {
                SendReply(player, lang.GetMessage("NoPermission", this, PlayerID));
                return;
            }

            string currentTime = TOD_Sky.Instance.Cycle.DateTime.ToString("HH:mm");
            SendReply(player, string.Format(lang.GetMessage("Time", this, PlayerID), currentTime));
        }

        [ChatCommand("time")]
		private void TimeCommand(BasePlayer player, string command, string[] args)
		{
            if (!_initialized)
                return;

            string PlayerID = player.UserIDString;

            if (!permission.UserHasPermission(PlayerID, CanUsePermission))
            {
                SendReply(player, lang.GetMessage("NoPermission", this, PlayerID));
                return;
            }

            string currentTime = TOD_Sky.Instance.Cycle.DateTime.ToString("HH:mm");
            SendReply(player, string.Format(lang.GetMessage("Time", this, PlayerID), currentTime));
        }
        #endregion​
eDnGDLKz3OKt1tE.jpg always2nv

If you want both commands then you'd just have to repeat the same chat command block, one being "time" other being "hora". For the second one you pasted you'll have to rename the function as well. They both can't be: "private void TimeCommand" so make the other one something like private void TimeCommand2 or HoraCommand.

For example:

That would not be a good example, and copy/pasting the code is not necessary.

You can register as many commands as you'd want to a single, shared method manually via cmd.AddChatCommand; or if using universal/covalence commands you can simply add them as an alias with the [Command("command1", "command2")] attribute.

Examples (while a bit more advanced, using localization) can be found in most of these found (look for AddLocalizedCommand) at this link: uMod - Plugins

Wulf

That would not be a good example, and copy/pasting the code is not necessary.

You can register as many commands as you'd want to a single, shared method manually via cmd.AddChatCommand; or if using universal/covalence commands you can simply add them as an alias with the [Command("command1", "command2")] attribute.

Examples (while a bit more advanced, using localization) can be found in most of these found (look for AddLocalizedCommand) at this link: uMod - Plugins

Thanks! I knew there'd be an easy way to add multiple commands LOL I literally just got into Oxide development about ten minutes before writing this comment but felt bad it went 5 days with no response!

I was just giving him a rudimentary method to do what he wanted as it's a very tiny plugin so I figured it wouldn't cause any crazy performance impacts and doubt they would want to go in-depth with anything code-wise. That's me jumping to conclusions though!

I knew it was bad advice to begin with so I'm probably a terrible person lmao. A noob helping a noob is never good.

Thanks again though @Wulf!