2024-03-15 08:27:35 -04:00
|
|
|
using TwitchChatTTS.Chat.Commands.Parameters;
|
|
|
|
using TwitchLib.Client.Models;
|
|
|
|
|
|
|
|
namespace TwitchChatTTS.Chat.Commands
|
|
|
|
{
|
|
|
|
public abstract class ChatCommand
|
|
|
|
{
|
|
|
|
public string Name { get; }
|
|
|
|
public string Description { get; }
|
|
|
|
public IList<ChatCommandParameter> Parameters { get => _parameters.AsReadOnly(); }
|
|
|
|
private IList<ChatCommandParameter> _parameters;
|
|
|
|
|
2024-06-16 20:19:31 -04:00
|
|
|
public ChatCommand(string name, string description)
|
|
|
|
{
|
2024-03-15 08:27:35 -04:00
|
|
|
Name = name;
|
|
|
|
Description = description;
|
|
|
|
_parameters = new List<ChatCommandParameter>();
|
|
|
|
}
|
|
|
|
|
2024-06-16 20:19:31 -04:00
|
|
|
protected void AddParameter(ChatCommandParameter parameter, bool optional = false)
|
|
|
|
{
|
|
|
|
if (parameter != null && parameter.Clone() is ChatCommandParameter p) {
|
|
|
|
_parameters.Add(optional ? p.Permissive() : p);
|
|
|
|
}
|
2024-03-15 08:27:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public abstract Task<bool> CheckPermissions(ChatMessage message, long broadcasterId);
|
|
|
|
public abstract Task Execute(IList<string> args, ChatMessage message, long broadcasterId);
|
|
|
|
}
|
|
|
|
}
|