This commit is contained in:
2022-07-05 16:43:23 +03:00
parent 059228ca52
commit c80fe33e6d
12 changed files with 215 additions and 153 deletions

4
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,4 @@
{
"rpc.enabled": true,
"discord.enabled": true
}

View File

@@ -14,28 +14,28 @@
"CMD_Utils.dll": {}
}
},
"Discord.Net/3.6.1": {
"Discord.Net/3.7.2": {
"dependencies": {
"Discord.Net.Commands": "3.6.1",
"Discord.Net.Core": "3.6.1",
"Discord.Net.Interactions": "3.6.1",
"Discord.Net.Rest": "3.6.1",
"Discord.Net.WebSocket": "3.6.1",
"Discord.Net.Webhook": "3.6.1"
"Discord.Net.Commands": "3.7.2",
"Discord.Net.Core": "3.7.2",
"Discord.Net.Interactions": "3.7.2",
"Discord.Net.Rest": "3.7.2",
"Discord.Net.WebSocket": "3.7.2",
"Discord.Net.Webhook": "3.7.2"
}
},
"Discord.Net.Commands/3.6.1": {
"Discord.Net.Commands/3.7.2": {
"dependencies": {
"Discord.Net.Core": "3.6.1"
"Discord.Net.Core": "3.7.2"
},
"runtime": {
"lib/net6.0/Discord.Net.Commands.dll": {
"assemblyVersion": "3.6.1.0",
"fileVersion": "3.6.1.0"
"assemblyVersion": "3.7.2.0",
"fileVersion": "3.7.2.0"
}
}
},
"Discord.Net.Core/3.6.1": {
"Discord.Net.Core/3.7.2": {
"dependencies": {
"Newtonsoft.Json": "13.0.1",
"System.Collections.Immutable": "5.0.0",
@@ -44,59 +44,59 @@
},
"runtime": {
"lib/net6.0/Discord.Net.Core.dll": {
"assemblyVersion": "3.6.1.0",
"fileVersion": "3.6.1.0"
"assemblyVersion": "3.7.2.0",
"fileVersion": "3.7.2.0"
}
}
},
"Discord.Net.Interactions/3.6.1": {
"Discord.Net.Interactions/3.7.2": {
"dependencies": {
"Discord.Net.Core": "3.6.1",
"Discord.Net.Rest": "3.6.1",
"Discord.Net.WebSocket": "3.6.1",
"Discord.Net.Core": "3.7.2",
"Discord.Net.Rest": "3.7.2",
"Discord.Net.WebSocket": "3.7.2",
"Microsoft.Extensions.DependencyInjection.Abstractions": "5.0.0",
"System.Collections.Immutable": "5.0.0",
"System.Reactive": "5.0.0"
},
"runtime": {
"lib/net6.0/Discord.Net.Interactions.dll": {
"assemblyVersion": "3.6.1.0",
"fileVersion": "3.6.1.0"
"assemblyVersion": "3.7.2.0",
"fileVersion": "3.7.2.0"
}
}
},
"Discord.Net.Rest/3.6.1": {
"Discord.Net.Rest/3.7.2": {
"dependencies": {
"Discord.Net.Core": "3.6.1"
"Discord.Net.Core": "3.7.2"
},
"runtime": {
"lib/net6.0/Discord.Net.Rest.dll": {
"assemblyVersion": "3.6.1.0",
"fileVersion": "3.6.1.0"
"assemblyVersion": "3.7.2.0",
"fileVersion": "3.7.2.0"
}
}
},
"Discord.Net.Webhook/3.6.1": {
"Discord.Net.Webhook/3.7.2": {
"dependencies": {
"Discord.Net.Core": "3.6.1",
"Discord.Net.Rest": "3.6.1"
"Discord.Net.Core": "3.7.2",
"Discord.Net.Rest": "3.7.2"
},
"runtime": {
"lib/net6.0/Discord.Net.Webhook.dll": {
"assemblyVersion": "3.6.1.0",
"fileVersion": "3.6.1.0"
"assemblyVersion": "3.7.2.0",
"fileVersion": "3.7.2.0"
}
}
},
"Discord.Net.WebSocket/3.6.1": {
"Discord.Net.WebSocket/3.7.2": {
"dependencies": {
"Discord.Net.Core": "3.6.1",
"Discord.Net.Rest": "3.6.1"
"Discord.Net.Core": "3.7.2",
"Discord.Net.Rest": "3.7.2"
},
"runtime": {
"lib/net6.0/Discord.Net.WebSocket.dll": {
"assemblyVersion": "3.6.1.0",
"fileVersion": "3.6.1.0"
"assemblyVersion": "3.7.2.0",
"fileVersion": "3.7.2.0"
}
}
},
@@ -147,7 +147,7 @@
"System.ValueTuple/4.5.0": {},
"PluginManager/1.0.0": {
"dependencies": {
"Discord.Net": "3.6.1"
"Discord.Net": "3.7.2"
},
"runtime": {
"PluginManager.dll": {}
@@ -161,54 +161,54 @@
"serviceable": false,
"sha512": ""
},
"Discord.Net/3.6.1": {
"Discord.Net/3.7.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-TfcL/HG57fVt//WVJ2XyF2PlytY9IYkkwwkPLIhvu5FW4wf9rm7+N8RPh4qtELLfsa5ES0FK2RbgYjABRR9AjA==",
"path": "discord.net/3.6.1",
"hashPath": "discord.net.3.6.1.nupkg.sha512"
"sha512": "sha512-FAiCLGu5rp6+Z10FjKbbJ6LLpKjbMBGpozixkJlz5LZvuncPx8f4AWFAw7pBecKUuAh983qiZ8CZYZcNXsI4qg==",
"path": "discord.net/3.7.2",
"hashPath": "discord.net.3.7.2.nupkg.sha512"
},
"Discord.Net.Commands/3.6.1": {
"Discord.Net.Commands/3.7.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-kK7m571yzSzPd93o+n8Z+TfvX62BT1HtOEZIWXKwXWO8itP/sgqBNExjWK/6DOpkbD6+khc2f3rp+TA0rJD88g==",
"path": "discord.net.commands/3.6.1",
"hashPath": "discord.net.commands.3.6.1.nupkg.sha512"
"sha512": "sha512-aOEGP04X64htsTr7ozKj9qHpmvOfitSw5gfR8Tw9TX0+FdswD2LNL2KfOAIaxRKZmRTm34aXQEJrVq0K8AptmQ==",
"path": "discord.net.commands/3.7.2",
"hashPath": "discord.net.commands.3.7.2.nupkg.sha512"
},
"Discord.Net.Core/3.6.1": {
"Discord.Net.Core/3.7.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-ibVjQiWzgqh0GyP/GXE2kv3TA/9ysmmNFG/WmRE7GepQQAXXGxVUO9IMJ8h14EvIXMQ0m0DktMe5DkUnilo3Ag==",
"path": "discord.net.core/3.6.1",
"hashPath": "discord.net.core.3.6.1.nupkg.sha512"
"sha512": "sha512-apwswc6LjN4dj3u27SO3Hr56Jzl91wzReahieoD7IQhV+BJQaRxhTRiEEWFTrBzHfeFHEOQ7r6vZnra3zeFhKA==",
"path": "discord.net.core/3.7.2",
"hashPath": "discord.net.core.3.7.2.nupkg.sha512"
},
"Discord.Net.Interactions/3.6.1": {
"Discord.Net.Interactions/3.7.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-WGOxz6SMUu4WS5b/JdrhlwQletcplBIYqvjFBBDfnqE+uNJqcNGtAdyjLqIILfXGx8aSSSSYZSCeAUa7FZ8Yew==",
"path": "discord.net.interactions/3.6.1",
"hashPath": "discord.net.interactions.3.6.1.nupkg.sha512"
"sha512": "sha512-dwGhEdDB0yyo/lGtjwIDVZmsuD52di7lIZWu/sBtvvA05dMgYZq5S6ILdsBXjOyaHeXd+EV4YMlj2VS/rm619w==",
"path": "discord.net.interactions/3.7.2",
"hashPath": "discord.net.interactions.3.7.2.nupkg.sha512"
},
"Discord.Net.Rest/3.6.1": {
"Discord.Net.Rest/3.7.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-T7RRThIS23roFEJwTL1l7aawjVyn7ZB5yH3tMge0d6TiCzzp4V4FAZ+ArTt19LHRFhPly90v8V3sWqmTMN+5Zg==",
"path": "discord.net.rest/3.6.1",
"hashPath": "discord.net.rest.3.6.1.nupkg.sha512"
"sha512": "sha512-dyp8YaMBNJ837EH1KNz2PNGZqc2y71WFd1+pdldF+pLQJ3Gf/+V7685paAR7bQw7yFNyqEBR/QRBCNp+QIQ7Wg==",
"path": "discord.net.rest/3.7.2",
"hashPath": "discord.net.rest.3.7.2.nupkg.sha512"
},
"Discord.Net.Webhook/3.6.1": {
"Discord.Net.Webhook/3.7.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-xikKHIGAIMz0BzHkaTKb48DNpFjKW8mvJjLJSezJ1xQOu+laHNk/hav4qxVtyZz7HSI/vGTkmlq9hKVhWzpaUA==",
"path": "discord.net.webhook/3.6.1",
"hashPath": "discord.net.webhook.3.6.1.nupkg.sha512"
"sha512": "sha512-da3i/mTq2y7mfj3xlHH14S4PivHbflJCVr8OUikJtQrxBOxvPkqP7ZYk3Y9S28q0K8qik+TUjCcjL5gELKrh/A==",
"path": "discord.net.webhook/3.7.2",
"hashPath": "discord.net.webhook.3.7.2.nupkg.sha512"
},
"Discord.Net.WebSocket/3.6.1": {
"Discord.Net.WebSocket/3.7.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-hF22Xy7URlVEDQZ69INOgzPvFUsIDfd+r6U+1yF9HWdBn3d4THnvAAhkv1TraSx/T/MKS7g+jvk/HZ3mh5S3aw==",
"path": "discord.net.websocket/3.6.1",
"hashPath": "discord.net.websocket.3.6.1.nupkg.sha512"
"sha512": "sha512-pYCd6ET44ADaNiyEw82TaJnR7TKYHfrKCytWFWMPL5faJhoh260avZn3Hwunlf331lEQ0f4K1CujPkQbNuq7kQ==",
"path": "discord.net.websocket/3.7.2",
"hashPath": "discord.net.websocket.3.7.2.nupkg.sha512"
},
"Microsoft.Extensions.DependencyInjection.Abstractions/5.0.0": {
"type": "package",

Binary file not shown.

View File

@@ -14,28 +14,28 @@
"MusicCommands.dll": {}
}
},
"Discord.Net/3.6.1": {
"Discord.Net/3.7.2": {
"dependencies": {
"Discord.Net.Commands": "3.6.1",
"Discord.Net.Core": "3.6.1",
"Discord.Net.Interactions": "3.6.1",
"Discord.Net.Rest": "3.6.1",
"Discord.Net.WebSocket": "3.6.1",
"Discord.Net.Webhook": "3.6.1"
"Discord.Net.Commands": "3.7.2",
"Discord.Net.Core": "3.7.2",
"Discord.Net.Interactions": "3.7.2",
"Discord.Net.Rest": "3.7.2",
"Discord.Net.WebSocket": "3.7.2",
"Discord.Net.Webhook": "3.7.2"
}
},
"Discord.Net.Commands/3.6.1": {
"Discord.Net.Commands/3.7.2": {
"dependencies": {
"Discord.Net.Core": "3.6.1"
"Discord.Net.Core": "3.7.2"
},
"runtime": {
"lib/net6.0/Discord.Net.Commands.dll": {
"assemblyVersion": "3.6.1.0",
"fileVersion": "3.6.1.0"
"assemblyVersion": "3.7.2.0",
"fileVersion": "3.7.2.0"
}
}
},
"Discord.Net.Core/3.6.1": {
"Discord.Net.Core/3.7.2": {
"dependencies": {
"Newtonsoft.Json": "13.0.1",
"System.Collections.Immutable": "5.0.0",
@@ -44,59 +44,59 @@
},
"runtime": {
"lib/net6.0/Discord.Net.Core.dll": {
"assemblyVersion": "3.6.1.0",
"fileVersion": "3.6.1.0"
"assemblyVersion": "3.7.2.0",
"fileVersion": "3.7.2.0"
}
}
},
"Discord.Net.Interactions/3.6.1": {
"Discord.Net.Interactions/3.7.2": {
"dependencies": {
"Discord.Net.Core": "3.6.1",
"Discord.Net.Rest": "3.6.1",
"Discord.Net.WebSocket": "3.6.1",
"Discord.Net.Core": "3.7.2",
"Discord.Net.Rest": "3.7.2",
"Discord.Net.WebSocket": "3.7.2",
"Microsoft.Extensions.DependencyInjection.Abstractions": "5.0.0",
"System.Collections.Immutable": "5.0.0",
"System.Reactive": "5.0.0"
},
"runtime": {
"lib/net6.0/Discord.Net.Interactions.dll": {
"assemblyVersion": "3.6.1.0",
"fileVersion": "3.6.1.0"
"assemblyVersion": "3.7.2.0",
"fileVersion": "3.7.2.0"
}
}
},
"Discord.Net.Rest/3.6.1": {
"Discord.Net.Rest/3.7.2": {
"dependencies": {
"Discord.Net.Core": "3.6.1"
"Discord.Net.Core": "3.7.2"
},
"runtime": {
"lib/net6.0/Discord.Net.Rest.dll": {
"assemblyVersion": "3.6.1.0",
"fileVersion": "3.6.1.0"
"assemblyVersion": "3.7.2.0",
"fileVersion": "3.7.2.0"
}
}
},
"Discord.Net.Webhook/3.6.1": {
"Discord.Net.Webhook/3.7.2": {
"dependencies": {
"Discord.Net.Core": "3.6.1",
"Discord.Net.Rest": "3.6.1"
"Discord.Net.Core": "3.7.2",
"Discord.Net.Rest": "3.7.2"
},
"runtime": {
"lib/net6.0/Discord.Net.Webhook.dll": {
"assemblyVersion": "3.6.1.0",
"fileVersion": "3.6.1.0"
"assemblyVersion": "3.7.2.0",
"fileVersion": "3.7.2.0"
}
}
},
"Discord.Net.WebSocket/3.6.1": {
"Discord.Net.WebSocket/3.7.2": {
"dependencies": {
"Discord.Net.Core": "3.6.1",
"Discord.Net.Rest": "3.6.1"
"Discord.Net.Core": "3.7.2",
"Discord.Net.Rest": "3.7.2"
},
"runtime": {
"lib/net6.0/Discord.Net.WebSocket.dll": {
"assemblyVersion": "3.6.1.0",
"fileVersion": "3.6.1.0"
"assemblyVersion": "3.7.2.0",
"fileVersion": "3.7.2.0"
}
}
},
@@ -147,7 +147,7 @@
"System.ValueTuple/4.5.0": {},
"PluginManager/1.0.0": {
"dependencies": {
"Discord.Net": "3.6.1"
"Discord.Net": "3.7.2"
},
"runtime": {
"PluginManager.dll": {}
@@ -161,54 +161,54 @@
"serviceable": false,
"sha512": ""
},
"Discord.Net/3.6.1": {
"Discord.Net/3.7.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-TfcL/HG57fVt//WVJ2XyF2PlytY9IYkkwwkPLIhvu5FW4wf9rm7+N8RPh4qtELLfsa5ES0FK2RbgYjABRR9AjA==",
"path": "discord.net/3.6.1",
"hashPath": "discord.net.3.6.1.nupkg.sha512"
"sha512": "sha512-FAiCLGu5rp6+Z10FjKbbJ6LLpKjbMBGpozixkJlz5LZvuncPx8f4AWFAw7pBecKUuAh983qiZ8CZYZcNXsI4qg==",
"path": "discord.net/3.7.2",
"hashPath": "discord.net.3.7.2.nupkg.sha512"
},
"Discord.Net.Commands/3.6.1": {
"Discord.Net.Commands/3.7.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-kK7m571yzSzPd93o+n8Z+TfvX62BT1HtOEZIWXKwXWO8itP/sgqBNExjWK/6DOpkbD6+khc2f3rp+TA0rJD88g==",
"path": "discord.net.commands/3.6.1",
"hashPath": "discord.net.commands.3.6.1.nupkg.sha512"
"sha512": "sha512-aOEGP04X64htsTr7ozKj9qHpmvOfitSw5gfR8Tw9TX0+FdswD2LNL2KfOAIaxRKZmRTm34aXQEJrVq0K8AptmQ==",
"path": "discord.net.commands/3.7.2",
"hashPath": "discord.net.commands.3.7.2.nupkg.sha512"
},
"Discord.Net.Core/3.6.1": {
"Discord.Net.Core/3.7.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-ibVjQiWzgqh0GyP/GXE2kv3TA/9ysmmNFG/WmRE7GepQQAXXGxVUO9IMJ8h14EvIXMQ0m0DktMe5DkUnilo3Ag==",
"path": "discord.net.core/3.6.1",
"hashPath": "discord.net.core.3.6.1.nupkg.sha512"
"sha512": "sha512-apwswc6LjN4dj3u27SO3Hr56Jzl91wzReahieoD7IQhV+BJQaRxhTRiEEWFTrBzHfeFHEOQ7r6vZnra3zeFhKA==",
"path": "discord.net.core/3.7.2",
"hashPath": "discord.net.core.3.7.2.nupkg.sha512"
},
"Discord.Net.Interactions/3.6.1": {
"Discord.Net.Interactions/3.7.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-WGOxz6SMUu4WS5b/JdrhlwQletcplBIYqvjFBBDfnqE+uNJqcNGtAdyjLqIILfXGx8aSSSSYZSCeAUa7FZ8Yew==",
"path": "discord.net.interactions/3.6.1",
"hashPath": "discord.net.interactions.3.6.1.nupkg.sha512"
"sha512": "sha512-dwGhEdDB0yyo/lGtjwIDVZmsuD52di7lIZWu/sBtvvA05dMgYZq5S6ILdsBXjOyaHeXd+EV4YMlj2VS/rm619w==",
"path": "discord.net.interactions/3.7.2",
"hashPath": "discord.net.interactions.3.7.2.nupkg.sha512"
},
"Discord.Net.Rest/3.6.1": {
"Discord.Net.Rest/3.7.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-T7RRThIS23roFEJwTL1l7aawjVyn7ZB5yH3tMge0d6TiCzzp4V4FAZ+ArTt19LHRFhPly90v8V3sWqmTMN+5Zg==",
"path": "discord.net.rest/3.6.1",
"hashPath": "discord.net.rest.3.6.1.nupkg.sha512"
"sha512": "sha512-dyp8YaMBNJ837EH1KNz2PNGZqc2y71WFd1+pdldF+pLQJ3Gf/+V7685paAR7bQw7yFNyqEBR/QRBCNp+QIQ7Wg==",
"path": "discord.net.rest/3.7.2",
"hashPath": "discord.net.rest.3.7.2.nupkg.sha512"
},
"Discord.Net.Webhook/3.6.1": {
"Discord.Net.Webhook/3.7.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-xikKHIGAIMz0BzHkaTKb48DNpFjKW8mvJjLJSezJ1xQOu+laHNk/hav4qxVtyZz7HSI/vGTkmlq9hKVhWzpaUA==",
"path": "discord.net.webhook/3.6.1",
"hashPath": "discord.net.webhook.3.6.1.nupkg.sha512"
"sha512": "sha512-da3i/mTq2y7mfj3xlHH14S4PivHbflJCVr8OUikJtQrxBOxvPkqP7ZYk3Y9S28q0K8qik+TUjCcjL5gELKrh/A==",
"path": "discord.net.webhook/3.7.2",
"hashPath": "discord.net.webhook.3.7.2.nupkg.sha512"
},
"Discord.Net.WebSocket/3.6.1": {
"Discord.Net.WebSocket/3.7.2": {
"type": "package",
"serviceable": true,
"sha512": "sha512-hF22Xy7URlVEDQZ69INOgzPvFUsIDfd+r6U+1yF9HWdBn3d4THnvAAhkv1TraSx/T/MKS7g+jvk/HZ3mh5S3aw==",
"path": "discord.net.websocket/3.6.1",
"hashPath": "discord.net.websocket.3.6.1.nupkg.sha512"
"sha512": "sha512-pYCd6ET44ADaNiyEw82TaJnR7TKYHfrKCytWFWMPL5faJhoh260avZn3Hwunlf331lEQ0f4K1CujPkQbNuq7kQ==",
"path": "discord.net.websocket/3.7.2",
"hashPath": "discord.net.websocket.3.7.2.nupkg.sha512"
},
"Microsoft.Extensions.DependencyInjection.Abstractions/5.0.0": {
"type": "package",

Binary file not shown.

Binary file not shown.

View File

@@ -24,9 +24,9 @@ public class Random : DBCommand
if (a > b)
{
var x = a;
a = b;
b = x;
var temp = a;
a = b;
b = temp;
}
await message.Channel.SendMessageAsync("Your random generated number is " + new System.Random().Next(a, b));

View File

@@ -37,7 +37,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Discord.Net" Version="3.6.1" />
<PackageReference Include="Discord.Net" Version="3.7.2" />
</ItemGroup>
<ItemGroup>

View File

@@ -42,4 +42,12 @@ internal class Command
/// The prefix that is used for the command
/// </summary>
public char PrefixUsed { get; }
}
public class ConsoleCommand
{
public string CommandName { get; set; }
public string Description { get; set; }
public string Usage { get; set; }
public Action<string[]> Action { get; set; }
}

View File

@@ -14,10 +14,9 @@ namespace PluginManager.Items;
public class ConsoleCommandsHandler
{
private static readonly PluginsManager manager = new("https://sethdiscordbot.000webhostapp.com/Storage/Discord%20Bot/Plugins");
public static List<Tuple<string, string, Action<string[]>>> commandList = new();
private readonly DiscordSocketClient? client;
private static readonly PluginsManager manager = new PluginsManager("https://sethdiscordbot.000webhostapp.com/Storage/Discord%20Bot/Plugins");
public static List<ConsoleCommand> commandList = new List<ConsoleCommand>();
private readonly DiscordSocketClient? client;
public ConsoleCommandsHandler(DiscordSocketClient client)
{
@@ -31,19 +30,33 @@ public class ConsoleCommandsHandler
var pluginsLoaded = false;
commandList.Clear();
AddCommand("help", "Show help", args =>
AddCommand("help", "Show help", "help <command>", args =>
{
if (args.Length <= 1)
{
Console.WriteLine("Available commands:");
foreach (var command in commandList) Console.WriteLine("\t" + command.Item1 + " - " + command.Item2);
List<string[]> items = new List<string[]>();
items.Add(new [] {"-", "-", "-"});
items.Add(new [] {"Command", "Description", "Usage"});
items.Add(new[] {" ", " ", "Argument type: <optional> [required]"});
items.Add(new [] {"-", "-", "-"});
foreach (var command in commandList)
{
var pa = from p in command.Action.Method.GetParameters()
where p.Name != null select p.ParameterType.FullName;
items.Add(new[] { command.CommandName, command.Description, command.Usage });
}
items.Add(new [] {"-", "-", "-"});
Console_Utilities.FormatAndAlignTable(items);
}
else
{
foreach (var command in commandList)
if (command.Item1 == args[1])
if (command.CommandName == args[1])
{
Console.WriteLine(command.Item2);
Console.WriteLine(command.Description);
Console.WriteLine(command.Usage);
return;
}
@@ -83,7 +96,7 @@ public class ConsoleCommandsHandler
AddCommand("listplugs", "list available plugins", async () => { await manager.ListAvailablePlugins(); });
AddCommand("dwplug", "download plugin", async args =>
AddCommand("dwplug", "download plugin", "dwplug [name]", async args =>
{
if (args.Length == 1)
{
@@ -178,7 +191,7 @@ public class ConsoleCommandsHandler
);
AddCommand("value", "read value from VariableStack", args =>
AddCommand("value", "read value from VariableStack", "value [key]",args =>
{
if (args.Length != 2) return;
if (!Config.ContainsKey(args[1])) return;
@@ -188,7 +201,7 @@ public class ConsoleCommandsHandler
}
);
AddCommand("add", "add variable to the system variables\nadd [key] [value] [isReadOnly=true/false]", args =>
AddCommand("add", "add variable to the system variables","add [key] [value] [isReadOnly=true/false]", args =>
{
if (args.Length < 4) return;
var key = args[1];
@@ -223,7 +236,7 @@ public class ConsoleCommandsHandler
}
);
AddCommand("remv", "remove variable from system variables", args =>
AddCommand("remv", "remove variable from system variables", "remv [key]", args =>
{
if (args.Length < 2) return;
Config.RemoveKey(args[1]);
@@ -237,7 +250,7 @@ public class ConsoleCommandsHandler
data.Add(new[] { "-", "-" });
data.Add(new[] { "Key", "Value" });
data.Add(new[] { "-", "-" });
foreach (var kvp in d) data.Add(new string[] { kvp.Key, kvp.Value.ToString()! });
foreach (var kvp in d) data.Add(new[] { kvp.Key, kvp.Value.ToString()! });
data.Add(new[] { "-", "-" });
Console_Utilities.FormatAndAlignTable(data);
}
@@ -252,23 +265,31 @@ public class ConsoleCommandsHandler
Environment.Exit(0);
}
);
//Sort the commands by name
commandList.Sort((x, y) => x.CommandName.CompareTo(y.CommandName));
}
public static void AddCommand(string command, string description, Action<string[]> action)
public static void AddCommand(string command, string description, string usage, Action<string[]> action)
{
commandList.Add(new Tuple<string, string, Action<string[]>>(command, description, action));
commandList.Add(new ConsoleCommand
{
CommandName = command,
Description = description,
Action = action,
Usage = usage
});
Console.ForegroundColor = ConsoleColor.White;
Console_Utilities.WriteColorText($"Command &r{command} &cadded to the list of commands");
}
public static void AddCommand(string command, string description, Action action)
{
AddCommand(command, description, args => action());
AddCommand(command, description, command, args => action());
}
public static void RemoveCommand(string command)
{
commandList.RemoveAll(x => x.Item1 == command);
commandList.RemoveAll(x => x.CommandName == command);
}
public static bool CommandExists(string command)
@@ -276,17 +297,17 @@ public class ConsoleCommandsHandler
return !(GetCommand(command) is null);
}
public static Tuple<string, string, Action<string[]>>? GetCommand(string command)
public static ConsoleCommand? GetCommand(string command)
{
return commandList.FirstOrDefault(t => t.Item1 == command);
return commandList.FirstOrDefault(t => t.CommandName == command);
}
public void HandleCommand(string command)
{
var args = command.Split(' ');
foreach (var item in commandList.ToList())
if (item.Item1 == args[0])
item.Item3(args);
//Console.WriteLine($"Executing: {args[0]} with the following parameters: {args.MergeStrings(1)}");
if (item.CommandName == args[0])
item.Action(args);
//Console.WriteLine($"Executing: {args[0]} with the following parameters: {args.MergeStrings(1)}");
}
}

View File

@@ -260,6 +260,35 @@ namespace PluginManager.Others
return (obj ?? default)!;
}
/// <summary>
/// Check if all words from <paramref name="str"/> are in <paramref name="baseString"/><br/>
/// This function returns true if<br/>
/// 1. The <paramref name="str"/> is part of <paramref name="baseString"/><br/>
/// 2. The words (split by a space) of <paramref name="str"/> are located (separately) in <paramref name="baseString"/> <br/>
/// <example>
/// The following example will return <see langword="TRUE"/><br/>
/// <c>STRContains("Hello World !", "I type word Hello and then i typed word World !")</c><br/>
/// The following example will return <see langword="TRUE"/><br/>
/// <c>STRContains("Hello World !", "I typed Hello World !" </c><br/>
/// The following example will return <see langword="TRUE"/><br/>
/// <c>STRContains("Hello World", "I type World then Hello")</c><br/>
/// The following example will return <see langword="FALSE"/><br/>
/// <c>STRContains("Hello World !", "I typed Hello World")</c><br/>
/// </example>
/// </summary>
/// <param name="str">The string you are checking</param>
/// <param name="baseString">The main string that should contain <paramref name="str"/></param>
/// <returns></returns>
public static bool STRContains(this string str, string baseString)
{
if (baseString.Contains(str)) return true;
string[] array = str.Split(' ');
foreach (var s in array)
if (!baseString.Contains(s))
return false;
return true;
}
public static bool TryReadValueFromJson(string input, string codeName, out JsonElement element)
{
Stream text;

View File

@@ -16,7 +16,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Discord.Net" Version="3.6.1" />
<PackageReference Include="Discord.Net" Version="3.7.2" />
</ItemGroup>
</Project>