using Discord.WebSocket;
using PluginManager.Loaders;
using PluginManager.Others;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PluginManager.Items
{
internal class Command
{
///
/// The author of the command
///
public SocketUser Author;
///
/// The list of arguments
///
public List Arguments { get; private set; }
///
/// The command that is executed
///
public string CommandName { get; private set; }
///
/// The prefix that is used for the command
///
public char PrefixUsed { get; private set; }
///
/// The Command class contructor
///
/// The message that was sent
public Command(SocketMessage message)
{
this.Author = message.Author;
string[] data = message.Content.Split(' ');
if (data.Length > 1)
this.Arguments = new List(data.MergeStrings(1).Split(' '));
else this.Arguments = new List();
this.CommandName = data[0].Substring(1);
this.PrefixUsed = data[0][0];
}
///
/// The Command class contructor
///
/// The message string itself
/// True if the message has a prefix, false if not
public Command(string message, bool hasPrefix)
{
string[] data = message.Split(' ');
this.Author = null;
this.Arguments = new List(data.MergeStrings(1).Split(' '));
this.CommandName = data[0].Substring(1);
if (hasPrefix)
this.PrefixUsed = data[0][0];
else this.PrefixUsed = '\0'; //null
}
}
}