diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..6705416 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "rpc.enabled": true, + "discord.enabled": true +} \ No newline at end of file diff --git a/BUILDS/net6.0/CMD_Utils.deps.json b/BUILDS/net6.0/CMD_Utils.deps.json index f5694d6..4ac17c3 100644 --- a/BUILDS/net6.0/CMD_Utils.deps.json +++ b/BUILDS/net6.0/CMD_Utils.deps.json @@ -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", diff --git a/BUILDS/net6.0/CMD_Utils.dll b/BUILDS/net6.0/CMD_Utils.dll index ca84625..d30bcd7 100644 Binary files a/BUILDS/net6.0/CMD_Utils.dll and b/BUILDS/net6.0/CMD_Utils.dll differ diff --git a/BUILDS/net6.0/MusicCommands.deps.json b/BUILDS/net6.0/MusicCommands.deps.json index d7cba47..bf027a3 100644 --- a/BUILDS/net6.0/MusicCommands.deps.json +++ b/BUILDS/net6.0/MusicCommands.deps.json @@ -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", diff --git a/BUILDS/net6.0/MusicCommands.dll b/BUILDS/net6.0/MusicCommands.dll index 086a304..19a1e1a 100644 Binary files a/BUILDS/net6.0/MusicCommands.dll and b/BUILDS/net6.0/MusicCommands.dll differ diff --git a/BUILDS/net6.0/PluginManager.dll b/BUILDS/net6.0/PluginManager.dll index 7680527..809d3de 100644 Binary files a/BUILDS/net6.0/PluginManager.dll and b/BUILDS/net6.0/PluginManager.dll differ diff --git a/CMD_Utils/Random.cs b/CMD_Utils/Random.cs index 2cbc564..7a93e0d 100644 --- a/CMD_Utils/Random.cs +++ b/CMD_Utils/Random.cs @@ -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)); diff --git a/DiscordBot/DiscordBot.csproj b/DiscordBot/DiscordBot.csproj index f83d305..a46dc9d 100644 --- a/DiscordBot/DiscordBot.csproj +++ b/DiscordBot/DiscordBot.csproj @@ -37,7 +37,7 @@ - + diff --git a/PluginManager/Items/Command.cs b/PluginManager/Items/Command.cs index 12c67c3..ea8078b 100644 --- a/PluginManager/Items/Command.cs +++ b/PluginManager/Items/Command.cs @@ -42,4 +42,12 @@ internal class Command /// The prefix that is used for the command /// public char PrefixUsed { get; } +} + +public class ConsoleCommand +{ + public string CommandName { get; set; } + public string Description { get; set; } + public string Usage { get; set; } + public Action Action { get; set; } } \ No newline at end of file diff --git a/PluginManager/Items/ConsoleCommandsHandler.cs b/PluginManager/Items/ConsoleCommandsHandler.cs index 0636030..072161a 100644 --- a/PluginManager/Items/ConsoleCommandsHandler.cs +++ b/PluginManager/Items/ConsoleCommandsHandler.cs @@ -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>> commandList = new(); - private readonly DiscordSocketClient? client; + private static readonly PluginsManager manager = new PluginsManager("https://sethdiscordbot.000webhostapp.com/Storage/Discord%20Bot/Plugins"); + public static List commandList = new List(); + 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 ", args => { if (args.Length <= 1) { Console.WriteLine("Available commands:"); - foreach (var command in commandList) Console.WriteLine("\t" + command.Item1 + " - " + command.Item2); + List items = new List(); + items.Add(new [] {"-", "-", "-"}); + items.Add(new [] {"Command", "Description", "Usage"}); + items.Add(new[] {" ", " ", "Argument type: [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 action) + public static void AddCommand(string command, string description, string usage, Action action) { - commandList.Add(new Tuple>(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>? 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)}"); } } diff --git a/PluginManager/Others/Functions.cs b/PluginManager/Others/Functions.cs index 0f3c5fc..c1df251 100644 --- a/PluginManager/Others/Functions.cs +++ b/PluginManager/Others/Functions.cs @@ -260,6 +260,35 @@ namespace PluginManager.Others return (obj ?? default)!; } + /// + /// Check if all words from are in
+ /// This function returns true if
+ /// 1. The is part of
+ /// 2. The words (split by a space) of are located (separately) in
+ /// + /// The following example will return
+ /// STRContains("Hello World !", "I type word Hello and then i typed word World !")
+ /// The following example will return
+ /// STRContains("Hello World !", "I typed Hello World !"
+ /// The following example will return
+ /// STRContains("Hello World", "I type World then Hello")
+ /// The following example will return
+ /// STRContains("Hello World !", "I typed Hello World")
+ ///
+ ///
+ /// The string you are checking + /// The main string that should contain + /// + 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; diff --git a/PluginManager/PluginManager.csproj b/PluginManager/PluginManager.csproj index 7eafd1b..94853b4 100644 --- a/PluginManager/PluginManager.csproj +++ b/PluginManager/PluginManager.csproj @@ -16,7 +16,7 @@
- +