This commit is contained in:
2022-04-08 18:47:39 +03:00
parent 74c1fcede8
commit b57e132912
12 changed files with 145 additions and 54 deletions

View File

@@ -0,0 +1,43 @@
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
{
public SocketUser Author;
public List<string> Arguments { get; private set; }
public string CommandName { get; private set; }
public char PrefixUsed { get; private set; }
public Command(SocketMessage message)
{
this.Author = message.Author;
string[] data = message.Content.Split(' ');
if (data.Length > 1)
this.Arguments = new List<string>(data.MergeStrings(1).Split(' '));
else this.Arguments = new List<string>();
this.CommandName = data[0].Substring(1);
this.PrefixUsed = data[0][0];
}
public Command(string message, bool hasPrefix)
{
string[] data = message.Split(' ');
this.Author = null;
this.Arguments = new List<string>(data.MergeStrings(1).Split(' '));
this.CommandName = data[0].Substring(1);
if (hasPrefix)
this.PrefixUsed = data[0][0];
else this.PrefixUsed = '\0'; //null
}
}
}

View File

@@ -4,7 +4,8 @@ using System;
using System.Threading.Tasks;
using System.Linq;
using System.Collections.Generic;
using Discord.WebSocket;
using PluginManager.Items;
namespace PluginManager.Others
{
@@ -167,6 +168,12 @@ namespace PluginManager.Others
return OperatingSystem.UNKNOWN;
}
public static List<string> GetArguments(SocketMessage message)
{
Command command = new Command(message);
return command.Arguments;
}
/// <summary>
/// A way to create a table based on input data
/// EpicWings (Pasca Robert) este cel mai bun
@@ -223,9 +230,10 @@ namespace PluginManager.Others
/// <summary>
/// Write the text using color options( &g-green; &b-blue; &r-red; &c-clear; )
///
/// </summary>
/// <param name="text">The text</param>
public static void WriteColorText(string text)
public static void WriteColorText(string text, bool appendNewLine = true)
{
string[] words = text.Split(' ');
Dictionary<string, ConsoleColor> colors = new Dictionary<string, ConsoleColor>()
@@ -233,6 +241,7 @@ namespace PluginManager.Others
{"&g", ConsoleColor.Green },
{"&b", ConsoleColor.Blue },
{"&r", ConsoleColor.Red },
{"&m", ConsoleColor.Magenta },
{"&c", Console.ForegroundColor }
};
foreach (string word in words)
@@ -244,10 +253,11 @@ namespace PluginManager.Others
Console.ForegroundColor = colors[prefix];
}
string m = word.Replace("&g", "").Replace("&b", "").Replace("&r", "").Replace("&c", "");
string m = word.Replace("&g", "").Replace("&b", "").Replace("&r", "").Replace("&c", "").Replace("&m", "");
Console.Write(m + " ");
}
Console.Write('\n');
if (appendNewLine)
Console.Write('\n');
}
/// <summary>