using System;

namespace StreamBuddy.PluginInterface.Commands
{
    /// <summary>
    /// Parity values for command timeout
    /// </summary>
    public enum TimeoutParity
    {
        /// <summary>
        /// The command will be timed per user.
        /// </summary>
        PerUser,
        /// <summary>
        /// The command will be timed per stream.
        /// </summary>
        PerStream,
        /// <summary>
        /// The command will be timed globally for all streams and users.
        /// </summary>
        Global
    }

    /// <summary>
    /// Defines a command that's accessible to the users in a stream.
    /// This attribute should only be used on methods inside of a class with a <seealso cref="StreamBuddy.PluginInterface.Features.FeatureAttribute"/>.
    /// </summary>
    [AttributeUsage(AttributeTargets.Method), System.Diagnostics.DebuggerDisplay("{Name}")]
    public class CommandAttribute : Attribute
    {
        /// <summary>
        /// The name of the command, case-insensitive and will be executed by '!<para>Name</para>'
        /// </summary>
        public string Name { get; private set; }
        /// <summary>
        /// A short description of the command and what it does
        /// </summary>
        public string Description { get; set; }
        /// <summary>
        /// A string describing the usage, in the form of: "!command &lt;arg&gt; [&lt;optional arg&gt;]
        /// </summary>
        /// <returns></returns>
        public string Usage { get; set; }
        /// <summary>
        /// The minimal rank the user must have to be able to execute this command.
        /// If they lack the required rank their execution attempt will be ignored.
        /// </summary>
        public Users.UserRank MinRank { get; set; }
        /// <summary>
        /// The timeout length before the command can be used again, in seconds.
        /// </summary>
        public int Timeout { get; set; }
        /// <summary>
        /// The parity of the timeout length.
        /// Defaults to <seealso cref="TimeoutParity.PerUser"/>
        /// </summary>
        public TimeoutParity TimeoutParity { get; set; }

        /// <summary>
        /// Define a user-accessible command
        /// </summary>
        /// <param name="Name">Name of the command, case-insensitive, without the '!'</param>
        public CommandAttribute(string Name)
        {
            this.Name = Name;
			this.MinRank = Users.UserRank.Guest;
        }
    }
}
