diff --git a/.vscode/launch.json b/.vscode/launch.json
deleted file mode 100644
index 2fc441b..0000000
--- a/.vscode/launch.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "version": "0.2.0",
- "configurations": [
- {
- // Use IntelliSense to find out which attributes exist for C# debugging
- // Use hover for the description of the existing attributes
- // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
- "name": ".NET Core Launch (console)",
- "type": "coreclr",
- "request": "launch",
- "preLaunchTask": "build",
- // If you have changed target frameworks, make sure to update the program path.
- "program": "${workspaceFolder}/DiscordBot/bin/Debug/net5.0/DiscordBot.dll",
- "args": [],
- "cwd": "${workspaceFolder}/DiscordBot",
- // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
- "console": "internalConsole",
- "stopAtEntry": false
- },
- {
- "name": ".NET Core Attach",
- "type": "coreclr",
- "request": "attach"
- }
- ]
-}
\ No newline at end of file
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/.vscode/solution-explorer/class.cs-template b/.vscode/solution-explorer/class.cs-template
deleted file mode 100644
index 20c7109..0000000
--- a/.vscode/solution-explorer/class.cs-template
+++ /dev/null
@@ -1,5 +0,0 @@
-namespace {{namespace}};
-
-public class {{name}}
-{
-}
diff --git a/.vscode/solution-explorer/class.ts-template b/.vscode/solution-explorer/class.ts-template
deleted file mode 100644
index ff2edef..0000000
--- a/.vscode/solution-explorer/class.ts-template
+++ /dev/null
@@ -1,3 +0,0 @@
-export class {{name}} {
-
-}
\ No newline at end of file
diff --git a/.vscode/solution-explorer/class.vb-template b/.vscode/solution-explorer/class.vb-template
deleted file mode 100644
index 38ef67f..0000000
--- a/.vscode/solution-explorer/class.vb-template
+++ /dev/null
@@ -1,9 +0,0 @@
-Imports System
-
-Namespace {{namespace}}
-
- Public Class {{name}}
-
- End Class
-
-End Namespace
diff --git a/.vscode/solution-explorer/default.ts-template b/.vscode/solution-explorer/default.ts-template
deleted file mode 100644
index 04af870..0000000
--- a/.vscode/solution-explorer/default.ts-template
+++ /dev/null
@@ -1,3 +0,0 @@
-export default {{name}} {
-
-}
\ No newline at end of file
diff --git a/.vscode/solution-explorer/enum.cs-template b/.vscode/solution-explorer/enum.cs-template
deleted file mode 100644
index 1ded8c0..0000000
--- a/.vscode/solution-explorer/enum.cs-template
+++ /dev/null
@@ -1,5 +0,0 @@
-namespace {{namespace}};
-
-public enum {{name}}
-{
-}
diff --git a/.vscode/solution-explorer/interface.cs-template b/.vscode/solution-explorer/interface.cs-template
deleted file mode 100644
index bf25cbb..0000000
--- a/.vscode/solution-explorer/interface.cs-template
+++ /dev/null
@@ -1,5 +0,0 @@
-namespace {{namespace}};
-
-public interface {{name}}
-{
-}
diff --git a/.vscode/solution-explorer/interface.ts-template b/.vscode/solution-explorer/interface.ts-template
deleted file mode 100644
index 3ea404b..0000000
--- a/.vscode/solution-explorer/interface.ts-template
+++ /dev/null
@@ -1,3 +0,0 @@
-export interface {{name}} {
-
-}
\ No newline at end of file
diff --git a/.vscode/solution-explorer/template-list.json b/.vscode/solution-explorer/template-list.json
deleted file mode 100644
index 2849622..0000000
--- a/.vscode/solution-explorer/template-list.json
+++ /dev/null
@@ -1,46 +0,0 @@
-{
- "templates": [
- {
- "name": "Class",
- "extension": "cs",
- "file": "./class.cs-template",
- "parameters": "./template-parameters.js"
- },
- {
- "name": "Interface",
- "extension": "cs",
- "file": "./interface.cs-template",
- "parameters": "./template-parameters.js"
- },
- {
- "name": "Enum",
- "extension": "cs",
- "file": "./enum.cs-template",
- "parameters": "./template-parameters.js"
- },
- {
- "name": "Class",
- "extension": "ts",
- "file": "./class.ts-template",
- "parameters": "./template-parameters.js"
- },
- {
- "name": "Interface",
- "extension": "ts",
- "file": "./interface.ts-template",
- "parameters": "./template-parameters.js"
- },
- {
- "name": "Default",
- "extension": "ts",
- "file": "./default.ts-template",
- "parameters": "./template-parameters.js"
- },
- {
- "name": "Class",
- "extension": "vb",
- "file": "./class.vb-template",
- "parameters": "./template-parameters.js"
- }
- ]
-}
\ No newline at end of file
diff --git a/.vscode/solution-explorer/template-parameters.js b/.vscode/solution-explorer/template-parameters.js
deleted file mode 100644
index daba8b2..0000000
--- a/.vscode/solution-explorer/template-parameters.js
+++ /dev/null
@@ -1,17 +0,0 @@
-var path = require("path");
-
-module.exports = function(filename, projectPath, folderPath) {
- var namespace = "Unknown";
- if (projectPath) {
- namespace = path.basename(projectPath, path.extname(projectPath));
- if (folderPath) {
- namespace += "." + folderPath.replace(path.dirname(projectPath), "").substring(1).replace(/[\\\/]/g, ".");
- }
- namespace = namespace.replace(/[\\\-]/g, "_");
- }
-
- return {
- namespace: namespace,
- name: path.basename(filename, path.extname(filename))
- }
-};
\ No newline at end of file
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
deleted file mode 100644
index adf4d42..0000000
--- a/.vscode/tasks.json
+++ /dev/null
@@ -1,42 +0,0 @@
-{
- "version": "2.0.0",
- "tasks": [
- {
- "label": "build",
- "command": "dotnet",
- "type": "process",
- "args": [
- "build",
- "${workspaceFolder}/DiscordBot/DiscordBot.csproj",
- "/property:GenerateFullPaths=true",
- "/consoleloggerparameters:NoSummary"
- ],
- "problemMatcher": "$msCompile"
- },
- {
- "label": "publish",
- "command": "dotnet",
- "type": "process",
- "args": [
- "publish",
- "${workspaceFolder}/DiscordBot/DiscordBot.csproj",
- "/property:GenerateFullPaths=true",
- "/consoleloggerparameters:NoSummary"
- ],
- "problemMatcher": "$msCompile"
- },
- {
- "label": "watch",
- "command": "dotnet",
- "type": "process",
- "args": [
- "watch",
- "run",
- "${workspaceFolder}/DiscordBot/DiscordBot.csproj",
- "/property:GenerateFullPaths=true",
- "/consoleloggerparameters:NoSummary"
- ],
- "problemMatcher": "$msCompile"
- }
- ]
-}
\ 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 dac55eb..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 6be9c72..bb6f20f 100644
Binary files a/BUILDS/net6.0/PluginManager.dll and b/BUILDS/net6.0/PluginManager.dll differ
diff --git a/BUILDS/net6.0/Plugins/Commands/CMD_LevelingSystem.dll b/BUILDS/net6.0/Plugins/Commands/CMD_LevelingSystem.dll
new file mode 100644
index 0000000..c1c7ecf
Binary files /dev/null and b/BUILDS/net6.0/Plugins/Commands/CMD_LevelingSystem.dll differ
diff --git a/BUILDS/net6.0/Plugins/Commands/CMD_Utils.dll b/BUILDS/net6.0/Plugins/Commands/CMD_Utils.dll
new file mode 100644
index 0000000..d30bcd7
Binary files /dev/null and b/BUILDS/net6.0/Plugins/Commands/CMD_Utils.dll differ
diff --git a/BUILDS/net6.0/Plugins/Commands/MusicCommands.dll b/BUILDS/net6.0/Plugins/Commands/MusicCommands.dll
new file mode 100644
index 0000000..b690a8c
Binary files /dev/null and b/BUILDS/net6.0/Plugins/Commands/MusicCommands.dll differ
diff --git a/BUILDS/net6.0/Plugins/Events/EVE_LevelingSystem.dll b/BUILDS/net6.0/Plugins/Events/EVE_LevelingSystem.dll
new file mode 100644
index 0000000..efc3f15
Binary files /dev/null and b/BUILDS/net6.0/Plugins/Events/EVE_LevelingSystem.dll differ
diff --git a/CMD_Utils/CMD_Utils.csproj b/CMD_Utils/CMD_Utils.csproj
index 9d3154b..40c79f6 100644
--- a/CMD_Utils/CMD_Utils.csproj
+++ b/CMD_Utils/CMD_Utils.csproj
@@ -2,6 +2,7 @@
net6.0
+
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/Discord/Core/CommandHandler.cs b/DiscordBot/Discord/Core/CommandHandler.cs
index b876858..3a87dbc 100644
--- a/DiscordBot/Discord/Core/CommandHandler.cs
+++ b/DiscordBot/Discord/Core/CommandHandler.cs
@@ -121,7 +121,6 @@ internal class CommandHandler
plugin.Execute(context, message, client, false);
Functions.WriteLogFile($"[{message.Author.Id}] Executed command : " + plugin.Command);
- return;
}
}
}
diff --git a/DiscordBot/DiscordBot.csproj b/DiscordBot/DiscordBot.csproj
index f83d305..da11f94 100644
--- a/DiscordBot/DiscordBot.csproj
+++ b/DiscordBot/DiscordBot.csproj
@@ -8,6 +8,7 @@
False
True
+ 1.0.0.1
@@ -37,7 +38,7 @@
-
+
diff --git a/DiscordBot/Program.cs b/DiscordBot/Program.cs
index 7a9f374..c78d07d 100644
--- a/DiscordBot/Program.cs
+++ b/DiscordBot/Program.cs
@@ -1,264 +1,312 @@
-using DiscordBot.Discord.Core;
-using PluginManager;
-using PluginManager.Items;
-using PluginManager.Others;
-using System;
+using System;
+using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
+using DiscordBot.Discord.Core;
+using PluginManager;
+using PluginManager.Items;
using PluginManager.Online;
+using PluginManager.Others;
-namespace DiscordBot
+namespace DiscordBot;
+
+public class Program
{
- public class Program
+ private static bool loadPluginsOnStartup;
+ private static bool listPluginsAtStartup;
+
+ ///
+ /// The main entry point for the application.
+ ///
+ [STAThread]
+ [Obsolete]
+ public static void Main(string[] args)
{
- private static bool loadPluginsOnStartup = false;
- private static bool listPluginsAtStartup = false;
+ Directory.CreateDirectory("./Data/Resources");
+ Directory.CreateDirectory("./Data/Plugins/Commands");
+ Directory.CreateDirectory("./Data/Plugins/Events");
+ PreLoadComponents().Wait();
- ///
- /// The main entry point for the application.
- ///
- [STAThread]
- [Obsolete]
- public static void Main(string[] args)
+ if (!Config.ContainsKey("token") || Config.GetValue("token") == null || Config.GetValue("token")?.Length != 70)
{
- Directory.CreateDirectory("./Data/Resources");
- Directory.CreateDirectory("./Data/Plugins/Commands");
- Directory.CreateDirectory("./Data/Plugins/Events");
- PreLoadComponents().Wait();
+ Console.WriteLine("Please insert your token");
+ Console.Write("Token = ");
+ var token = Console.ReadLine();
+ if (token?.Length == 59 || token?.Length == 70)
+ Config.AddValueToVariables("token", token, true);
+ else
+ Console.WriteLine("Invalid token");
- if (!Config.ContainsKey("token") || Config.GetValue("token") == null || Config.GetValue("token")?.Length != 70)
- {
- while (true)
- {
- Console.WriteLine("Please insert your token");
- Console.Write("Token = ");
- string token = Console.ReadLine();
- if (token?.Length == 59 || token?.Length == 70)
- Config.AddValueToVariables("token", token, true);
- else
- {
- Console.WriteLine("Invalid token");
- continue;
- }
+ Console.WriteLine("Please insert your prefix (max. 1 character long):");
+ Console.WriteLine("For a prefix longer then one character, the first character will be saved and the others will be ignored.\n No spaces or numbers allowed");
+ Console.Write("Prefix = ");
+ var prefix = Console.ReadLine()![0];
- Console.WriteLine("Please insert your prefix (max. 1 character long):");
- Console.WriteLine("For a prefix longer then one character, the first character will be saved and the others will be ignored.\n No spaces or numbers allowed");
- Console.Write("Prefix = ");
- char prefix = Console.ReadLine()![0];
-
- if (prefix == ' ' || char.IsDigit(prefix)) continue;
- Config.AddValueToVariables("prefix", prefix.ToString(), false);
- break;
- }
- }
-
- if (!Config.ContainsKey("prefix"))
- {
- Console.WriteLine("Please insert your prefix (max. 1 character long):");
- Console.WriteLine("For a prefix longer then one character, the first character will be saved and the others will be ignored.\n No spaces or numbers allowed");
- Console.Write("Prefix = ");
- char prefix = Console.ReadLine()![0];
-
- if (prefix == ' ' || char.IsDigit(prefix)) return;
- Config.AddValueToVariables("prefix", prefix.ToString(), false);
- }
-
- HandleInput(args).Wait();
+ if (prefix == ' ' || char.IsDigit(prefix)) return;
+ Config.AddValueToVariables("prefix", prefix.ToString(), false);
}
- ///
- /// The main loop for the discord bot
- ///
- /// The discord booter used to start the application
- private static Task NoGUI(Boot discordbooter)
+ if (!Config.ContainsKey("prefix") || Config.GetValue("prefix") == default)
{
- ConsoleCommandsHandler consoleCommandsHandler = new ConsoleCommandsHandler(discordbooter.client);
- if (loadPluginsOnStartup) consoleCommandsHandler.HandleCommand("lp");
- if (listPluginsAtStartup) consoleCommandsHandler.HandleCommand("listplugs");
- Config.SaveConfig();
- while (true)
- {
- Console.ForegroundColor = ConsoleColor.White;
- string cmd = Console.ReadLine();
- consoleCommandsHandler.HandleCommand(cmd);
- }
+ Console.WriteLine("Please insert your prefix (max. 1 character long):");
+ Console.WriteLine("For a prefix longer then one character, the first character will be saved and the others will be ignored.\n No spaces or numbers allowed");
+ Console.Write("Prefix = ");
+ var prefix = Console.ReadLine()![0];
+ if (prefix == ' ') return;
+ Config.AddValueToVariables("prefix", prefix.ToString(), false);
}
- ///
- /// Start the bot without user interface
- ///
- /// Returns the boot loader for the Discord Bot
- private static async Task StartNoGUI()
- {
- Console.Clear();
- Console.ForegroundColor = ConsoleColor.DarkYellow;
- Console.WriteLine("Discord BOT for Cross Platform");
- Console.WriteLine("Created by: Wizzy\nDiscord: Wizzy#9181");
+ HandleInput(args).Wait();
+ }
+
+ ///
+ /// The main loop for the discord bot
+ ///
+ /// The discord booter used to start the application
+ private static Task NoGUI(Boot discordbooter)
+ {
+ var consoleCommandsHandler = new ConsoleCommandsHandler(discordbooter.client);
+ if (loadPluginsOnStartup) consoleCommandsHandler.HandleCommand("lp");
+ if (listPluginsAtStartup) consoleCommandsHandler.HandleCommand("listplugs");
+
+ Config.SaveConfig();
+
+
+ while (true)
+ {
Console.ForegroundColor = ConsoleColor.White;
- Console.WriteLine("============================ Discord BOT - Cross Platform ============================");
+ var cmd = Console.ReadLine();
+ if (!consoleCommandsHandler.HandleCommand(cmd))
+ Console.WriteLine("Failed to run command " + cmd);
+ }
+ }
+ ///
+ /// Start the bot without user interface
+ ///
+ /// Returns the boot loader for the Discord Bot
+ private static async Task StartNoGUI()
+ {
+ Console.Clear();
+ Console.ForegroundColor = ConsoleColor.DarkYellow;
+
+ List startupMessageList = await ServerCom.ReadTextFromFile("https://raw.githubusercontent.com/Wizzy69/installer/discord-bot-files/StartupMessage");
+
+ foreach (var message in startupMessageList) Console.WriteLine(message);
+
+ Console.WriteLine($"Running on version: {Config.GetValue("Version") ?? System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString()}");
+ Console.WriteLine($"Git URL: {Config.GetValue("GitURL") ?? " Could not find Git URL"}");
+
+ Console.ForegroundColor = ConsoleColor.White;
+ Console.WriteLine($"============================ LOG ============================");
+
+ try
+ {
+ var token = Config.GetValue("token");
+ var prefix = Config.GetValue("prefix");
+
+ var discordbooter = new Boot(token, prefix);
+ await discordbooter.Awake();
+ return discordbooter;
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex);
+ return null;
+ }
+ }
+
+ ///
+ /// Clear folder
+ ///
+ /// Directory path
+ private static Task ClearFolder(string d)
+ {
+ var files = Directory.GetFiles(d);
+ var fileNumb = files.Length;
+ for (var i = 0; i < fileNumb; i++)
+ {
+ File.Delete(files[i]);
+ Console.WriteLine("Deleting : " + files[i]);
+ }
+
+ return Task.CompletedTask;
+ }
+
+ ///
+ /// Handle user input arguments from the startup of the application
+ ///
+ /// The arguments
+ private static async Task HandleInput(string[] args)
+ {
+ var len = args.Length;
+
+ if (len == 3 && args[0] == "/download")
+ {
+ var url = args[1];
+ var location = args[2];
+
+ await ServerCom.DownloadFileAsync(url, location);
+
+ return;
+ }
+
+ if (len > 0 && (args.Contains("--cmd") || args.Contains("--args") || args.Contains("--nomessage")))
+ {
+ if (args.Contains("lp") || args.Contains("loadplugins")) loadPluginsOnStartup = true;
+ if (args.Contains("listplugs")) listPluginsAtStartup = true;
+ len = 0;
+ }
+
+
+ if (len == 0 || (args[0] != "--exec" && args[0] != "--execute"))
+ {
+ var b = await StartNoGUI();
+ await NoGUI(b);
+ return;
+ }
+
+
+ Console.ForegroundColor = ConsoleColor.DarkYellow;
+ Console.WriteLine("Execute command interface noGUI\n\n");
+ Console.WriteLine(
+ "\tCommand name\t\t\t\tDescription\n" +
+ "-- help | -help\t\t ------ \tDisplay the help message\n" +
+ "--reset-full\t\t ------ \tReset all files (clear files)\n" +
+ "--reset-logs\t\t ------ \tClear up the output folder\n" +
+ "--start\t\t ------ \tStart the bot\n" +
+ "exit\t\t\t ------ \tClose the application"
+ );
+ while (true)
+ {
+ Console.ForegroundColor = ConsoleColor.White;
+ Console.Write("> ");
+ var message = Console.ReadLine().Split(' ');
+
+ switch (message[0])
+ {
+ case "--help":
+ case "-help":
+ Console.ForegroundColor = ConsoleColor.DarkYellow;
+ Console.WriteLine(
+ "\tCommand name\t\t\t\tDescription\n" +
+ "-- help | -help\t\t ------ \tDisplay the help message\n" +
+ "--reset-full\t\t ------ \tReset all files (clear files)\n" +
+ "--reset-settings\t ------ \tReset only bot settings\n" +
+ "--reset-logs\t\t ------ \tClear up the output folder\n" +
+ "--start\t\t ------ \tStart the bot\n" +
+ "exit\t\t\t ------ \tClose the application"
+ );
+ break;
+ case "--reset-full":
+ await ClearFolder("./Data/Resources/");
+ await ClearFolder("./Output/Logs/");
+ await ClearFolder("./Output/Errors");
+ await ClearFolder("./Data/Languages/");
+ await ClearFolder("./Data/Plugins/Commands");
+ await ClearFolder("./Data/Plugins/Events");
+ Console.WriteLine("Successfully cleared all folders");
+ break;
+ case "--reset-logs":
+ await ClearFolder("./Output/Logs");
+ await ClearFolder("./Output/Errors");
+ Console.WriteLine("Successfully cleard logs folder");
+ break;
+ case "--exit":
+ case "exit":
+ Environment.Exit(0);
+ break;
+ case "--start":
+ var booter = await StartNoGUI();
+ await NoGUI(booter);
+ return;
+
+ default:
+ Console.WriteLine("Failed to execute command " + message[0]);
+ break;
+ }
+ }
+ }
+
+ private static async Task PreLoadComponents()
+ {
+ await Config.LoadConfig();
+ if (Config.ContainsKey("DeleteLogsAtStartup"))
+ if (Config.GetValue("DeleteLogsAtStartup"))
+ foreach (var file in Directory.GetFiles("./Output/Logs/"))
+ File.Delete(file);
+ List OnlineDefaultKeys = await ServerCom.ReadTextFromFile("https://raw.githubusercontent.com/Wizzy69/installer/discord-bot-files/SetupKeys");
+
+ Config.PluginConfig.Load();
+
+ if (!Config.ContainsKey("Version"))
+ Config.AddValueToVariables("Version", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(), false);
+ else
+ Config.SetValue("Version", System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
+
+ foreach (var key in OnlineDefaultKeys)
+ {
+ if (key.Length <= 3 || !key.Contains(' ')) continue;
+ string[] s = key.Split(' ');
try
{
- string token = Config.GetValue("token");
- string prefix = Config.GetValue("prefix");
-
- var discordbooter = new Boot(token, prefix);
- await discordbooter.Awake();
- return discordbooter;
+ Config.GetAndAddValueToVariable(s[0], s[1], s[2].Equals("true", StringComparison.CurrentCultureIgnoreCase));
}
catch (Exception ex)
{
- Console.WriteLine(ex);
- return null;
+ Functions.WriteErrFile(ex.Message);
}
}
- ///
- /// Clear folder
- ///
- /// Directory path
- private static Task ClearFolder(string d)
+ List onlineSettingsList = await ServerCom.ReadTextFromFile("https://raw.githubusercontent.com/Wizzy69/installer/discord-bot-files/OnlineData");
+ foreach (var key in onlineSettingsList)
{
- string[] files = Directory.GetFiles(d);
- int fileNumb = files.Length;
- for (var i = 0; i < fileNumb; i++)
- {
- File.Delete(files[i]);
- Console.WriteLine("Deleting : " + files[i]);
- }
+ if (key.Length <= 3 || !key.Contains(' ')) continue;
- return Task.CompletedTask;
- }
-
- ///
- /// Handle user input arguments from the startup of the application
- ///
- /// The arguments
- private static async Task HandleInput(string[] args)
- {
- int len = args.Length;
- if (len == 1 && args[0] == "--help")
+ string[] s = key.Split(' ');
+ switch (s[0])
{
- Console.WriteLine("Available commands:\n--exec -> start the bot with tools enabled");
- return;
- }
-
- if (len == 1 && args[0] == "--logout")
- {
- File.Delete(Functions.dataFolder + "config.json");
- await Task.Run(async () =>
+ case "CurrentVersion":
+ string newVersion = s[1];
+ if (!newVersion.Equals(Config.GetValue("Version")))
{
- await Task.Delay(1000);
- Environment.Exit(0x08);
- }
- );
- return;
- }
+ Console.WriteLine("A new version has been released on github page.");
+ Console.WriteLine("Download the new version using the following link wrote in yellow");
+ Console_Utilities.WriteColorText("&y" + Config.GetValue("GitURL") + "&c");
- if (len >= 2 && args[0] == "--encrypt")
- {
- string s2e = args.MergeStrings(1);
- Console.WriteLine("MD5: " + await Cryptography.CreateMD5(s2e));
- Console.WriteLine("SHA356: " + await Cryptography.CreateSHA256(s2e));
- return;
- }
-
- if (len == 3 && args[0] == "/download")
- {
- string url = args[1];
- string location = args[2];
-
- await ServerCom.DownloadFileAsync(url, location);
-
- return;
- }
-
- if (len > 0 && (args.Contains("--cmd") || args.Contains("--args") || args.Contains("--nomessage")))
- {
- if (args.Contains("lp") || args.Contains("loadplugins")) loadPluginsOnStartup = true;
- if (args.Contains("listplugs")) listPluginsAtStartup = true;
- len = 0;
- }
-
-
- if (len == 0 || args[0] != "--exec" && args[0] != "--execute")
- {
- Boot b = await StartNoGUI();
- await NoGUI(b);
- return;
- }
-
-
- Console.ForegroundColor = ConsoleColor.DarkYellow;
- Console.WriteLine("Execute command interface noGUI\n\n");
- Console.WriteLine(
- "\tCommand name\t\t\t\tDescription\n" +
- "-- help | -help\t\t ------ \tDisplay the help message\n" +
- "--reset-full\t\t ------ \tReset all files (clear files)\n" +
- "--reset-logs\t\t ------ \tClear up the output folder\n" +
- "--start\t\t ------ \tStart the bot\n" +
- "exit\t\t\t ------ \tClose the application"
- );
- while (true)
- {
- Console.ForegroundColor = ConsoleColor.White;
- Console.Write("> ");
- string[] message = Console.ReadLine().Split(' ');
-
- switch (message[0])
- {
- case "--help":
- case "-help":
- Console.ForegroundColor = ConsoleColor.DarkYellow;
- Console.WriteLine(
- "\tCommand name\t\t\t\tDescription\n" +
- "-- help | -help\t\t ------ \tDisplay the help message\n" +
- "--reset-full\t\t ------ \tReset all files (clear files)\n" +
- "--reset-settings\t ------ \tReset only bot settings\n" +
- "--reset-logs\t\t ------ \tClear up the output folder\n" +
- "--start\t\t ------ \tStart the bot\n" +
- "exit\t\t\t ------ \tClose the application"
+ Console.WriteLine();
+ Console.WriteLine("Your product will work just fine on this outdated version, but an update is recommended.\n" +
+ "From now on, this version is no longer supported"
);
- break;
- case "--reset-full":
- await ClearFolder("./Data/Resources/");
- await ClearFolder("./Output/Logs/");
- await ClearFolder("./Output/Errors");
- await ClearFolder("./Data/Languages/");
- await ClearFolder("./Data/Plugins/Commands");
- await ClearFolder("./Data/Plugins/Events");
- Console.WriteLine("Successfully cleared all folders");
- break;
- case "--reset-logs":
- await ClearFolder("./Output/Logs");
- await ClearFolder("./Output/Errors");
- Console.WriteLine("Successfully cleard logs folder");
- break;
- case "--exit":
- case "exit":
- Environment.Exit(0);
- break;
- case "--start":
- Boot booter = await StartNoGUI();
- await NoGUI(booter);
- return;
+ Console_Utilities.WriteColorText("&rUse at your own risk&c");
- default:
- Console.WriteLine("Failed to execute command " + message[0]);
- break;
- }
+ Console_Utilities.WriteColorText("&mCurrent Version: " + Config.GetValue("Version") + "&c");
+ Console_Utilities.WriteColorText("&gNew Version: " + newVersion + "&c");
+
+ Console.WriteLine("\n\n");
+ await Task.Delay(1000);
+
+ int waitTime = 20; //wait time to proceed
+
+ Console.Write($"The bot will start in {waitTime} seconds");
+ while (waitTime > 0)
+ {
+ await Task.Delay(1000);
+ waitTime--;
+ Console.SetCursorPosition("The bot will start in ".Length, Console.CursorTop);
+ Console.Write(" ");
+ Console.SetCursorPosition("The bot will start in ".Length, Console.CursorTop);
+ Console.Write(waitTime + " seconds");
+ }
+ }
+
+ break;
}
}
- private static async Task PreLoadComponents()
- {
- await Config.LoadConfig();
- if (Config.ContainsKey("DeleteLogsAtStartup"))
- if (Config.GetValue("DeleteLogsAtStartup"))
- foreach (string file in Directory.GetFiles("./Output/Logs/"))
- File.Delete(file);
- }
+
+ Config.SaveConfig();
}
}
diff --git a/DiscordBotGUI/.gitignore b/DiscordBotGUI/.gitignore
deleted file mode 100644
index 8afdcb6..0000000
--- a/DiscordBotGUI/.gitignore
+++ /dev/null
@@ -1,454 +0,0 @@
-## Ignore Visual Studio temporary files, build results, and
-## files generated by popular Visual Studio add-ons.
-##
-## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
-
-# User-specific files
-*.rsuser
-*.suo
-*.user
-*.userosscache
-*.sln.docstates
-
-# User-specific files (MonoDevelop/Xamarin Studio)
-*.userprefs
-
-# Mono auto generated files
-mono_crash.*
-
-# Build results
-[Dd]ebug/
-[Dd]ebugPublic/
-[Rr]elease/
-[Rr]eleases/
-x64/
-x86/
-[Ww][Ii][Nn]32/
-[Aa][Rr][Mm]/
-[Aa][Rr][Mm]64/
-bld/
-[Bb]in/
-[Oo]bj/
-[Ll]og/
-[Ll]ogs/
-
-# Visual Studio 2015/2017 cache/options directory
-.vs/
-# Uncomment if you have tasks that create the project's static files in wwwroot
-#wwwroot/
-
-# Visual Studio 2017 auto generated files
-Generated\ Files/
-
-# MSTest test Results
-[Tt]est[Rr]esult*/
-[Bb]uild[Ll]og.*
-
-# NUnit
-*.VisualState.xml
-TestResult.xml
-nunit-*.xml
-
-# Build Results of an ATL Project
-[Dd]ebugPS/
-[Rr]eleasePS/
-dlldata.c
-
-# Benchmark Results
-BenchmarkDotNet.Artifacts/
-
-# .NET Core
-project.lock.json
-project.fragment.lock.json
-artifacts/
-
-# Tye
-.tye/
-
-# ASP.NET Scaffolding
-ScaffoldingReadMe.txt
-
-# StyleCop
-StyleCopReport.xml
-
-# Files built by Visual Studio
-*_i.c
-*_p.c
-*_h.h
-*.ilk
-*.meta
-*.obj
-*.iobj
-*.pch
-*.pdb
-*.ipdb
-*.pgc
-*.pgd
-*.rsp
-*.sbr
-*.tlb
-*.tli
-*.tlh
-*.tmp
-*.tmp_proj
-*_wpftmp.csproj
-*.log
-*.vspscc
-*.vssscc
-.builds
-*.pidb
-*.svclog
-*.scc
-
-# Chutzpah Test files
-_Chutzpah*
-
-# Visual C++ cache files
-ipch/
-*.aps
-*.ncb
-*.opendb
-*.opensdf
-*.sdf
-*.cachefile
-*.VC.db
-*.VC.VC.opendb
-
-# Visual Studio profiler
-*.psess
-*.vsp
-*.vspx
-*.sap
-
-# Visual Studio Trace Files
-*.e2e
-
-# TFS 2012 Local Workspace
-$tf/
-
-# Guidance Automation Toolkit
-*.gpState
-
-# ReSharper is a .NET coding add-in
-_ReSharper*/
-*.[Rr]e[Ss]harper
-*.DotSettings.user
-
-# TeamCity is a build add-in
-_TeamCity*
-
-# DotCover is a Code Coverage Tool
-*.dotCover
-
-# AxoCover is a Code Coverage Tool
-.axoCover/*
-!.axoCover/settings.json
-
-# Coverlet is a free, cross platform Code Coverage Tool
-coverage*.json
-coverage*.xml
-coverage*.info
-
-# Visual Studio code coverage results
-*.coverage
-*.coveragexml
-
-# NCrunch
-_NCrunch_*
-.*crunch*.local.xml
-nCrunchTemp_*
-
-# MightyMoose
-*.mm.*
-AutoTest.Net/
-
-# Web workbench (sass)
-.sass-cache/
-
-# Installshield output folder
-[Ee]xpress/
-
-# DocProject is a documentation generator add-in
-DocProject/buildhelp/
-DocProject/Help/*.HxT
-DocProject/Help/*.HxC
-DocProject/Help/*.hhc
-DocProject/Help/*.hhk
-DocProject/Help/*.hhp
-DocProject/Help/Html2
-DocProject/Help/html
-
-# Click-Once directory
-publish/
-
-# Publish Web Output
-*.[Pp]ublish.xml
-*.azurePubxml
-# Note: Comment the next line if you want to checkin your web deploy settings,
-# but database connection strings (with potential passwords) will be unencrypted
-*.pubxml
-*.publishproj
-
-# Microsoft Azure Web App publish settings. Comment the next line if you want to
-# checkin your Azure Web App publish settings, but sensitive information contained
-# in these scripts will be unencrypted
-PublishScripts/
-
-# NuGet Packages
-*.nupkg
-# NuGet Symbol Packages
-*.snupkg
-# The packages folder can be ignored because of Package Restore
-**/[Pp]ackages/*
-# except build/, which is used as an MSBuild target.
-!**/[Pp]ackages/build/
-# Uncomment if necessary however generally it will be regenerated when needed
-#!**/[Pp]ackages/repositories.config
-# NuGet v3's project.json files produces more ignorable files
-*.nuget.props
-*.nuget.targets
-
-# Microsoft Azure Build Output
-csx/
-*.build.csdef
-
-# Microsoft Azure Emulator
-ecf/
-rcf/
-
-# Windows Store app package directories and files
-AppPackages/
-BundleArtifacts/
-Package.StoreAssociation.xml
-_pkginfo.txt
-*.appx
-*.appxbundle
-*.appxupload
-
-# Visual Studio cache files
-# files ending in .cache can be ignored
-*.[Cc]ache
-# but keep track of directories ending in .cache
-!?*.[Cc]ache/
-
-# Others
-ClientBin/
-~$*
-*~
-*.dbmdl
-*.dbproj.schemaview
-*.jfm
-*.pfx
-*.publishsettings
-orleans.codegen.cs
-
-# Including strong name files can present a security risk
-# (https://github.com/github/gitignore/pull/2483#issue-259490424)
-#*.snk
-
-# Since there are multiple workflows, uncomment next line to ignore bower_components
-# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
-#bower_components/
-
-# RIA/Silverlight projects
-Generated_Code/
-
-# Backup & report files from converting an old project file
-# to a newer Visual Studio version. Backup files are not needed,
-# because we have git ;-)
-_UpgradeReport_Files/
-Backup*/
-UpgradeLog*.XML
-UpgradeLog*.htm
-ServiceFabricBackup/
-*.rptproj.bak
-
-# SQL Server files
-*.mdf
-*.ldf
-*.ndf
-
-# Business Intelligence projects
-*.rdl.data
-*.bim.layout
-*.bim_*.settings
-*.rptproj.rsuser
-*- [Bb]ackup.rdl
-*- [Bb]ackup ([0-9]).rdl
-*- [Bb]ackup ([0-9][0-9]).rdl
-
-# Microsoft Fakes
-FakesAssemblies/
-
-# GhostDoc plugin setting file
-*.GhostDoc.xml
-
-# Node.js Tools for Visual Studio
-.ntvs_analysis.dat
-node_modules/
-
-# Visual Studio 6 build log
-*.plg
-
-# Visual Studio 6 workspace options file
-*.opt
-
-# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
-*.vbw
-
-# Visual Studio LightSwitch build output
-**/*.HTMLClient/GeneratedArtifacts
-**/*.DesktopClient/GeneratedArtifacts
-**/*.DesktopClient/ModelManifest.xml
-**/*.Server/GeneratedArtifacts
-**/*.Server/ModelManifest.xml
-_Pvt_Extensions
-
-# Paket dependency manager
-.paket/paket.exe
-paket-files/
-
-# FAKE - F# Make
-.fake/
-
-# CodeRush personal settings
-.cr/personal
-
-# Python Tools for Visual Studio (PTVS)
-__pycache__/
-*.pyc
-
-# Cake - Uncomment if you are using it
-# tools/**
-# !tools/packages.config
-
-# Tabs Studio
-*.tss
-
-# Telerik's JustMock configuration file
-*.jmconfig
-
-# BizTalk build output
-*.btp.cs
-*.btm.cs
-*.odx.cs
-*.xsd.cs
-
-# OpenCover UI analysis results
-OpenCover/
-
-# Azure Stream Analytics local run output
-ASALocalRun/
-
-# MSBuild Binary and Structured Log
-*.binlog
-
-# NVidia Nsight GPU debugger configuration file
-*.nvuser
-
-# MFractors (Xamarin productivity tool) working folder
-.mfractor/
-
-# Local History for Visual Studio
-.localhistory/
-
-# BeatPulse healthcheck temp database
-healthchecksdb
-
-# Backup folder for Package Reference Convert tool in Visual Studio 2017
-MigrationBackup/
-
-# Ionide (cross platform F# VS Code tools) working folder
-.ionide/
-
-# Fody - auto-generated XML schema
-FodyWeavers.xsd
-
-##
-## Visual studio for Mac
-##
-
-
-# globs
-Makefile.in
-*.userprefs
-*.usertasks
-config.make
-config.status
-aclocal.m4
-install-sh
-autom4te.cache/
-*.tar.gz
-tarballs/
-test-results/
-
-# Mac bundle stuff
-*.dmg
-*.app
-
-# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
-# General
-.DS_Store
-.AppleDouble
-.LSOverride
-
-# Icon must end with two \r
-Icon
-
-
-# Thumbnails
-._*
-
-# Files that might appear in the root of a volume
-.DocumentRevisions-V100
-.fseventsd
-.Spotlight-V100
-.TemporaryItems
-.Trashes
-.VolumeIcon.icns
-.com.apple.timemachine.donotpresent
-
-# Directories potentially created on remote AFP share
-.AppleDB
-.AppleDesktop
-Network Trash Folder
-Temporary Items
-.apdisk
-
-# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
-# Windows thumbnail cache files
-Thumbs.db
-ehthumbs.db
-ehthumbs_vista.db
-
-# Dump file
-*.stackdump
-
-# Folder config file
-[Dd]esktop.ini
-
-# Recycle Bin used on file shares
-$RECYCLE.BIN/
-
-# Windows Installer files
-*.cab
-*.msi
-*.msix
-*.msm
-*.msp
-
-# Windows shortcuts
-*.lnk
-
-# JetBrains Rider
-.idea/
-*.sln.iml
-
-##
-## Visual Studio Code
-##
-.vscode/*
-!.vscode/settings.json
-!.vscode/tasks.json
-!.vscode/launch.json
-!.vscode/extensions.json
diff --git a/DiscordBotGUI/App.axaml b/DiscordBotGUI/App.axaml
deleted file mode 100644
index 49aa2e5..0000000
--- a/DiscordBotGUI/App.axaml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/DiscordBotGUI/App.axaml.cs b/DiscordBotGUI/App.axaml.cs
deleted file mode 100644
index 983b886..0000000
--- a/DiscordBotGUI/App.axaml.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using Avalonia;
-using Avalonia.Controls;
-using Avalonia.Controls.ApplicationLifetimes;
-using Avalonia.Markup.Xaml;
-
-namespace DiscordBotGUI;
-
-public class App : Application
-{
- public override void Initialize()
- {
- AvaloniaXamlLoader.Load(this);
- }
-
- public override void OnFrameworkInitializationCompleted()
- {
- if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) desktop.MainWindow = new AppUpdater { Width = 300, Height = 50, WindowStartupLocation = WindowStartupLocation.CenterScreen };
-
- base.OnFrameworkInitializationCompleted();
- }
-}
diff --git a/DiscordBotGUI/AppUpdater.axaml b/DiscordBotGUI/AppUpdater.axaml
deleted file mode 100644
index 939c0d6..0000000
--- a/DiscordBotGUI/AppUpdater.axaml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/DiscordBotGUI/AppUpdater.axaml.cs b/DiscordBotGUI/AppUpdater.axaml.cs
deleted file mode 100644
index fcf519f..0000000
--- a/DiscordBotGUI/AppUpdater.axaml.cs
+++ /dev/null
@@ -1,170 +0,0 @@
-using Avalonia.Controls;
-using PluginManager.Online;
-using PluginManager.Others;
-using System.Threading.Tasks;
-using System;
-using System.IO;
-using System.Threading;
-using PluginManager;
-
-namespace DiscordBotGUI
-{
- public partial class AppUpdater : Window
- {
- private string _version = "";
-
- public AppUpdater()
- {
- InitializeComponent();
- Config.LoadConfig().Wait();
- if (!File.Exists("./Version.txt"))
- {
- File.WriteAllText("./Version.txt", "DiscordBotVersion=0");
- DownloadDiscordBotClientNoGUIAsDLL();
- }
-
- if (!File.Exists("./DiscordBot.exe")) DownloadDiscordBotClientNoGUIAsDLL();
- Updates();
- }
-
- private async void DownloadDiscordBotClientNoGUIAsDLL()
- {
- //await Task.Delay(5000);
- string url_bot_dll = "https://sethdiscordbot.000webhostapp.com/Storage/Discord%20Bot/Updates/DiscordBot.zip";
- int actiontype = 0; //0 - downolad, 1- extract
- IProgress progress = new Progress((percent) =>
- {
- if (actiontype == 0)
- textBox1.Text = "Downloading DiscordBot ... " + MathF.Round(percent, 2) + "%";
- else
- textBox1.Text = "Extracting package ..." + MathF.Round(percent, 2) + "%";
- this.progressBar1.Value = percent;
- });
-
- this.progressBar1.IsIndeterminate = false;
- try
- {
- await ServerCom.DownloadFileAsync(url_bot_dll, "./DiscordBot.zip", progress);
-
- actiontype++;
-
- await Functions.ExtractArchive("./DiscordBot.zip", "./", progress);
- }
- catch
- {
- textBox1.Text = "Error downloading DiscordBot.dll. Server is not responding.";
-
- await Task.Delay(1000);
-
- new MainWindow() { Height = 425, Width = 500 }.Show();
- Close();
- }
- }
-
- private async void Updates()
- {
- this.progressBar1.IsIndeterminate = true;
- await Task.Delay(1000);
- if (!await CheckForUpdates())
- {
- //await Task.Delay(5000);
- textBox1.Text = $"You are running on the latest version ({_version}) !";
- await Task.Delay(2000);
- new MainWindow() { Height = 425, Width = 650 }.Show();
- this.Close();
- return;
- }
-
- string file = await DownloadNewUpdate();
- if (file == null)
- {
- textBox1.Text = "There was an error while downloading the update !";
- await Task.Delay(2000);
- new MainWindow() { Height = 425, Width = 650 }.Show();
- this.Close();
- return;
- }
-
- IProgress progress = new Progress((percent) => { this.progressBar1.Value = percent; });
-
- textBox1.Text = "Extracting update files ...";
- await Functions.ExtractArchive(file, "./", progress);
- progressBar1.IsIndeterminate = true;
- textBox1.Text = "Setting up the new version ...";
- File.Delete(file);
- File.WriteAllText("./Version.txt", "DiscordBotVersion=" + _version);
- await Task.Delay(5000);
- new MainWindow() { Height = 425, Width = 650 }.Show();
- this.Close();
- }
-
- private async Task DownloadNewUpdate()
- {
- string urlNewUpdateZip = (await ServerCom.ReadTextFromFile("https://sethdiscordbot.000webhostapp.com/Storage/Discord%20Bot/Updates/Version"))[1];
- int secondsPast = 0;
-
- bool isDownloading = true;
- this.progressBar1.IsIndeterminate = true;
- textBox1.Text = "Downloading update ...";
-
-
- IProgress downloaded = new Progress((bytes) =>
- {
- (double, string) download = Functions.ConvertBytes(bytes);
- textBox1.Text = $"Downloading update ... {Math.Round(download.Item1 / secondsPast, 2)} {download.Item2}/s";
- });
- IProgress progress = new Progress((percent) =>
- {
- progressBar1.IsIndeterminate = false;
- this.progressBar1.Value = percent;
- });
-
-
- string FileName = $"{urlNewUpdateZip.Split('/')[urlNewUpdateZip.Split('/').Length - 1]}";
- try
- {
- new Thread(new Task(() =>
- {
- while (isDownloading)
- {
- Thread.Sleep(1000);
- secondsPast++;
- }
- }).Start).Start();
- await ServerCom.DownloadFileAsync(urlNewUpdateZip, FileName, progress, downloaded);
- }
- catch
- {
- textBox1.Text = "Error downloading the update. Server is not responding.";
- isDownloading = false;
- await Task.Delay(1000);
- return null;
- }
-
- isDownloading = false;
- return FileName;
- }
-
- private async Task CheckForUpdates()
- {
- try
- {
- string current_version = Config.GetValue("Version");
- if (current_version == null)
- if (!Config.SetValue("Version", "0"))
- Config.AddValueToVariables("Version", "0", false);
- string latest_version = (await ServerCom.ReadTextFromFile("https://sethdiscordbot.000webhostapp.com/Storage/Discord%20Bot/Updates/Version"))[0];
- _version = latest_version;
- if (current_version != latest_version) { return true; }
-
- return false;
- }
- catch (Exception ex)
- {
- textBox1.Text = "Error while checking for updates. Server is not responding.";
- Functions.WriteErrFile(ex.Message);
- return false;
- }
- }
- }
-}
diff --git a/DiscordBotGUI/DiscordBotGUI.csproj b/DiscordBotGUI/DiscordBotGUI.csproj
deleted file mode 100644
index 568b686..0000000
--- a/DiscordBotGUI/DiscordBotGUI.csproj
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
- WinExe
- net6.0
- enable
-
- copyused
- true
- ..\BUILDS\DiscordBotUI\
-
-
- False
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/DiscordBotGUI/MainWindow.axaml b/DiscordBotGUI/MainWindow.axaml
deleted file mode 100644
index c011ce7..0000000
--- a/DiscordBotGUI/MainWindow.axaml
+++ /dev/null
@@ -1,39 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/DiscordBotGUI/MainWindow.axaml.cs b/DiscordBotGUI/MainWindow.axaml.cs
deleted file mode 100644
index b7cf17f..0000000
--- a/DiscordBotGUI/MainWindow.axaml.cs
+++ /dev/null
@@ -1,86 +0,0 @@
-using System.Diagnostics;
-using System.IO;
-using System.Threading.Tasks;
-using Avalonia.Controls;
-using DiscordBotGUI.Settings;
-using PluginManager;
-using PluginManager.Others;
-
-namespace DiscordBotGUI;
-
-public partial class MainWindow : Window
-{
- public MainWindow()
- {
- InitializeComponent();
-
- LoadElements();
- }
-
- private void LoadElements()
- {
- textBox3.Watermark = "Insert start arguments";
- if (File.Exists("./Version.txt")) label5.Content = Config.GetValue("Version");
- button1.Click += async (sender, e) =>
- {
- var token = textBox1.Text;
- var prefix = textBox2.Text;
- var args = "--nomessage " + textBox3.Text;
-
- if (!((token.Length == 70 || token.Length == 59) && prefix.Length == 1))
- {
- label4.Content = "Invalid Token or Prefix.\n(Prefix must be 1 character long and token must be 59 or 79 characters long)";
- await Task.Delay(5000);
- label4.Content = "";
- return;
- }
-
- Config.SetValue("token", token);
- Config.SetValue("prefix", prefix);
- RunDiscordBot(args);
- };
-
- commandsSettingMenuItem.Click += (sender, e) => new Commands() /*{ Height = 200, Width = 550 }*/.ShowDialog(this);
- eventsSettingMenuItem.Click += (sender, e) => new Events() /*{ Height = 200, Width = 550 }*/.ShowDialog(this);
- applicationVariablesMenuItem.Click += (sender, e) => new ApplicationVariables().ShowDialog(this);
-
- var folder = $"{Functions.dataFolder}DiscordBotCore.data";
- Directory.CreateDirectory(Functions.dataFolder);
- try
- {
- var botToken = Config.GetValue("token");
- var botPrefix = Config.GetValue("prefix");
- if (botToken == null || botPrefix == null)
- {
- textBox1.IsReadOnly = false;
- textBox2.IsReadOnly = false;
- textBox1.Watermark = "Insert Bot Token Here";
- textBox2.Watermark = "Insert Bot Prefix Here";
- }
- else
- {
- textBox1.Text = botToken;
- textBox2.Text = botPrefix;
- }
- }
- catch
- {
- textBox1.IsReadOnly = false;
- textBox2.IsReadOnly = false;
- textBox1.Watermark = "Insert Bot Token Here";
- textBox2.Watermark = "Insert Bot Prefix Here";
- }
- }
-
-
- private void RunDiscordBot(string args)
- {
- var os = Functions.GetOperatingSystem();
- if (os == OperatingSystem.WINDOWS)
- Process.Start("./DiscordBot.exe", args);
- else if (os == OperatingSystem.LINUX)
- Process.Start("./DiscordBot", args);
- else if (os == OperatingSystem.MAC_OS) Process.Start("./DiscordBot.app/Contents/MacOS/DiscordBot", args);
- Close();
- }
-}
diff --git a/DiscordBotGUI/Program.cs b/DiscordBotGUI/Program.cs
deleted file mode 100644
index 97ded76..0000000
--- a/DiscordBotGUI/Program.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System;
-using Avalonia;
-
-namespace DiscordBotGUI;
-
-internal class Program
-{
- // Initialization code. Don't use any Avalonia, third-party APIs or any
- // SynchronizationContext-reliant code before AppMain is called: things aren't initialized
- // yet and stuff might break.
- [STAThread]
- public static void Main(string[] args)
- {
- BuildAvaloniaApp()
- .StartWithClassicDesktopLifetime(args);
- }
-
- // Avalonia configuration, don't remove; also used by visual designer.
- public static AppBuilder BuildAvaloniaApp()
- {
- return AppBuilder.Configure()
- .UsePlatformDetect()
- .LogToTrace();
- }
-}
diff --git a/DiscordBotGUI/Settings/ApplicationVariables.axaml b/DiscordBotGUI/Settings/ApplicationVariables.axaml
deleted file mode 100644
index db6e433..0000000
--- a/DiscordBotGUI/Settings/ApplicationVariables.axaml
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/DiscordBotGUI/Settings/ApplicationVariables.axaml.cs b/DiscordBotGUI/Settings/ApplicationVariables.axaml.cs
deleted file mode 100644
index 2559134..0000000
--- a/DiscordBotGUI/Settings/ApplicationVariables.axaml.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-using Avalonia.Controls;
-using PluginManager;
-
-namespace DiscordBotGUI.Settings;
-
-public partial class ApplicationVariables : Window
-{
- public ApplicationVariables()
- {
- InitializeComponent();
- Load();
- }
-
- private void Load()
- {
- ClearEverything();
- button1.Click += (sedner, e) =>
- {
- var key = textBox2.Text;
- if (Config.ContainsKey(key))
- {
- ClearEverything();
- return;
- }
-
- var value = textBox3.Text;
- Config.AddValueToVariables(key, value, checkBox1.IsChecked!.Value);
- ClearEverything();
- };
- }
-
- private void ClearEverything()
- {
- textBox1.Text = "";
- textBox2.Text = "";
- textBox3.Text = "";
- checkBox1.IsChecked = false;
- var allvars = Config.GetAllVariables();
- foreach (var kvp in allvars) textBox1.Text += kvp.Key + " => " + kvp.Value + "\n";
- }
-}
diff --git a/DiscordBotGUI/Settings/Commands.axaml b/DiscordBotGUI/Settings/Commands.axaml
deleted file mode 100644
index 69ef101..0000000
--- a/DiscordBotGUI/Settings/Commands.axaml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/DiscordBotGUI/Settings/Commands.axaml.cs b/DiscordBotGUI/Settings/Commands.axaml.cs
deleted file mode 100644
index 27291d3..0000000
--- a/DiscordBotGUI/Settings/Commands.axaml.cs
+++ /dev/null
@@ -1,136 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Threading.Tasks;
-using Avalonia.Controls;
-using PluginManager.Online;
-using PluginManager.Others;
-using OperatingSystem = PluginManager.Others.OperatingSystem;
-
-namespace DiscordBotGUI.Settings;
-
-public partial class Commands : Window
-{
- private List commands = new();
-
- public Commands()
- {
- InitializeComponent();
- LoadData();
- LoadComboBox();
-
- button1.Click += async (sender, e) => { await Download(); };
- }
-
-
- private void LoadData()
- {
- try
- {
- textbox1.Text = "";
- Directory.CreateDirectory("./Data/Plugins/Commands/");
- var files = Directory.EnumerateFiles("./Data/Plugins/Commands/");
- if (files == null || files.Count() < 1) return;
- foreach (var file in files) textbox1.Text += file.Split('/')[file.Split('/').Length - 1] + "\n";
- }
- catch
- {
- }
- }
-
- private async void LoadComboBox()
- {
- comboBox1.Items = null;
- commands = await ServerCom.ReadTextFromFile("https://sethdiscordbot.000webhostapp.com/Storage/Discord%20Bot/Plugins");
- if (commands == null) return;
- var plugins = commands.ToArray();
- string OS;
- var OSG = Functions.GetOperatingSystem();
- if (OSG == OperatingSystem.WINDOWS)
- OS = "Windows";
- else if (OSG == OperatingSystem.LINUX)
- OS = "Linux";
- else
- OS = "MAC_OS";
- var data = new List();
- for (var i = 0; i < plugins.Length; i++)
- {
- if (!plugins[i].Contains(OS) || !plugins[i].Contains("Commands")) continue;
-
- var info = plugins[i].Split(',');
- try
- {
- if (Directory.EnumerateFiles("./Data/Plugins/Commands/").Any(x => x.EndsWith(info[0] + ".dll"))) continue;
- }
- catch
- {
- }
-
- data.Add($"{info[0]} - {info[1]} - {info[2]}");
- }
-
- comboBox1.Items = data;
- }
-
-
- private async Task Download()
- {
- if (comboBox1 == null || comboBox1.SelectedIndex == -1 || comboBox1.SelectedItem == null) return;
- var pluginName = comboBox1?.SelectedItem?.ToString()?.Split('-')[0].Trim();
-
- if (pluginName == null) return;
- var URL = (from s in commands
- where s.StartsWith(pluginName)
- select s.Split(',')[3].Trim()).FirstOrDefault();
-
- if (URL == null) return;
-
-
- IProgress progress = new Progress(async value =>
- {
- label1.Content = $"Downloading {pluginName} {MathF.Round(value, 2)}%";
- if (value == 1f)
- {
- label1.Content = "Successfully Downloaded " + pluginName;
- LoadData();
- LoadComboBox();
-
- await Task.Delay(5000);
- label1.Content = "";
- }
-
- progressBar1.Value = value;
- }
- );
-
- await ServerCom.DownloadFileAsync(URL, "./Data/Plugins/Commands/" + pluginName + ".dll", progress);
- var requirements = (from s in commands
- where s.StartsWith(pluginName) && s.Split(',').Length == 6
- select s.Split(',')[5].Trim()).FirstOrDefault();
-
- if (requirements == null) return;
- var req = await ServerCom.ReadTextFromFile(requirements);
- if (req == null) return;
-
- foreach (var requirement in req)
- {
- var info = requirement.Split(',');
- pluginName = info[1];
- progress.Report(0);
- await ServerCom.DownloadFileAsync(info[0], $"./{info[1]}", progress);
-
- await Task.Delay(1000);
-
- if (info[0].EndsWith(".zip"))
- {
- await Functions.ExtractArchive("./" + info[1], "./", progress);
- await Task.Delay(1000);
- }
- }
-
- progress.Report(100f);
- label1.Content = "Downloaded";
- progressBar1.Value = 100;
- }
-}
diff --git a/DiscordBotGUI/Settings/Events.axaml b/DiscordBotGUI/Settings/Events.axaml
deleted file mode 100644
index 57c0ca4..0000000
--- a/DiscordBotGUI/Settings/Events.axaml
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/DiscordBotGUI/Settings/Events.axaml.cs b/DiscordBotGUI/Settings/Events.axaml.cs
deleted file mode 100644
index 04eb48f..0000000
--- a/DiscordBotGUI/Settings/Events.axaml.cs
+++ /dev/null
@@ -1,135 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Threading.Tasks;
-using Avalonia.Controls;
-using PluginManager.Online;
-using PluginManager.Others;
-using OperatingSystem = PluginManager.Others.OperatingSystem;
-
-namespace DiscordBotGUI.Settings;
-
-public partial class Events : Window
-{
- private List events = new();
-
- public Events()
- {
- InitializeComponent();
- LoadData();
- LoadComboBox();
- button1.Click += async (sender, e) => { await Download(); };
- }
-
- private void LoadData()
- {
- //Read components from Commands Folder:
- //textbox1 = new TextBox();
- try
- {
- Directory.CreateDirectory("./Data/Plugins/Events/");
- textbox1.IsReadOnly = false;
- textbox1.Text = "";
- var files = Directory.EnumerateFiles("./Data/Plugins/Events/");
- if (files == null || files.Count() < 1) return;
- foreach (var file in files) textbox1.Text += file.Split('/')[file.Split('/').Length - 1] + "\n";
- }
- catch
- {
- }
- }
-
- private async void LoadComboBox()
- {
- comboBox1.Items = null;
- events = await ServerCom.ReadTextFromFile("https://sethdiscordbot.000webhostapp.com/Storage/Discord%20Bot/Plugins");
- if (events == null) return;
- var plugins = events.ToArray();
- string OS;
- var OSG = Functions.GetOperatingSystem();
- if (OSG == OperatingSystem.WINDOWS)
- OS = "Windows";
- else if (OSG == OperatingSystem.LINUX)
- OS = "Linux";
- else
- OS = "MAC_OS";
- var data = new List();
- for (var i = 0; i < plugins.Length; i++)
- {
- if (!plugins[i].Contains(OS) || !plugins[i].Contains("Event")) continue;
-
- var info = plugins[i].Split(',');
- try
- {
- if (Directory.EnumerateFiles("./Data/Plugins/Events/").Any(x => x.EndsWith(info[0] + ".dll"))) continue;
- }
- catch
- {
- }
-
-
- data.Add($"{info[0]} - {info[1]} - {info[2]}");
- }
-
- comboBox1.Items = data;
- }
-
- private async Task Download()
- {
- if (comboBox1 == null || comboBox1.SelectedIndex == -1 || comboBox1.SelectedItem == null) return;
- var pluginName = comboBox1?.SelectedItem?.ToString()?.Split('-')[0].Trim();
-
- if (pluginName == null) return;
- var URL = (from s in events
- where s.StartsWith(pluginName)
- select s.Split(',')[3].Trim()).FirstOrDefault();
-
- if (URL == null) return;
-
-
- IProgress progress = new Progress(async value =>
- {
- label1.Content = $"Downloading {pluginName} {MathF.Round(value, 2)}%";
- if (value == 1f)
- {
- label1.Content = "Successfully Downloaded " + pluginName;
- LoadData();
- LoadComboBox();
-
- await Task.Delay(5000);
- label1.Content = "";
- }
-
- progressBar1.Value = value;
- }
- );
-
- await ServerCom.DownloadFileAsync(URL, "./Data/Plugins/Events/" + pluginName + ".dll", progress);
- var requirements = (from s in events
- where s.StartsWith(pluginName) && s.Split(',').Length == 6
- select s.Split(',')[5].Trim()).FirstOrDefault();
-
- if (requirements == null) return;
- var req = await ServerCom.ReadTextFromFile(requirements);
- if (req == null) return;
-
- foreach (var requirement in req)
- {
- var info = requirement.Split(',');
- pluginName = info[1];
- progress.Report(0);
- await ServerCom.DownloadFileAsync(info[0], $"./{info[1]}", progress);
-
- await Task.Delay(1000);
-
- if (info[0].EndsWith(".zip"))
- {
- await Functions.ExtractArchive("./" + info[1], "./", progress);
- await Task.Delay(1000);
- }
- }
-
- label1.Content = "";
- }
-}
diff --git a/DiscordBotWithAPI.sln b/DiscordBotWithAPI.sln
index d88b05a..bccffb6 100644
--- a/DiscordBotWithAPI.sln
+++ b/DiscordBotWithAPI.sln
@@ -17,11 +17,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CMD_Utils", "CMD_Utils\CMD_
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MusicCommands", "MusicCommands\MusicCommands.csproj", "{B1B4976E-5112-4217-B57B-3A03C5207B6E}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DiscordBotGUI", "DiscordBotGUI\DiscordBotGUI.csproj", "{7B5899F0-0218-4537-8C74-6210ED2D3690}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EVE_LevelingSystem", "EVE_LevelingSystem\EVE_LevelingSystem.csproj", "{EEC445DC-0C4B-43EA-8694-606BA0390B77}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EVE_LevelingSystem", "EVE_LevelingSystem\EVE_LevelingSystem.csproj", "{EEC445DC-0C4B-43EA-8694-606BA0390B77}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CMD_LevelingSystem", "CMD_LevelingSystem\CMD_LevelingSystem.csproj", "{1A4E49FF-9A0A-4C54-AF35-CFFBA64353D9}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CMD_LevelingSystem", "CMD_LevelingSystem\CMD_LevelingSystem.csproj", "{1A4E49FF-9A0A-4C54-AF35-CFFBA64353D9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -45,10 +43,6 @@ Global
{B1B4976E-5112-4217-B57B-3A03C5207B6E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B1B4976E-5112-4217-B57B-3A03C5207B6E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B1B4976E-5112-4217-B57B-3A03C5207B6E}.Release|Any CPU.Build.0 = Release|Any CPU
- {7B5899F0-0218-4537-8C74-6210ED2D3690}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {7B5899F0-0218-4537-8C74-6210ED2D3690}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {7B5899F0-0218-4537-8C74-6210ED2D3690}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {7B5899F0-0218-4537-8C74-6210ED2D3690}.Release|Any CPU.Build.0 = Release|Any CPU
{EEC445DC-0C4B-43EA-8694-606BA0390B77}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EEC445DC-0C4B-43EA-8694-606BA0390B77}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EEC445DC-0C4B-43EA-8694-606BA0390B77}.Release|Any CPU.ActiveCfg = Release|Any CPU
diff --git a/MusicCommands/Data.cs b/MusicCommands/Data.cs
index 30a79b4..066af23 100644
--- a/MusicCommands/Data.cs
+++ b/MusicCommands/Data.cs
@@ -1,8 +1,7 @@
using Discord;
using Discord.Audio;
-using MusicCommands;
-namespace CMD_Utils.Music;
+namespace MusicCommands;
internal static class Data
{
diff --git a/MusicCommands/Leave.cs b/MusicCommands/Leave.cs
index 11fb2dd..3171489 100644
--- a/MusicCommands/Leave.cs
+++ b/MusicCommands/Leave.cs
@@ -2,7 +2,7 @@
using Discord.WebSocket;
using PluginManager.Interfaces;
-namespace CMD_Utils.Music;
+namespace MusicCommands;
internal class Leave : DBCommand
{
diff --git a/MusicCommands/MusicCommands.csproj b/MusicCommands/MusicCommands.csproj
index f64e6f5..9bd106b 100644
--- a/MusicCommands/MusicCommands.csproj
+++ b/MusicCommands/MusicCommands.csproj
@@ -3,6 +3,7 @@
net6.0
warnings
+ ..\DiscordBot\bin\Debug\net6.0\Data\Plugins\Commands\MusicCommands
diff --git a/MusicCommands/MusicPlayer.cs b/MusicCommands/MusicPlayer.cs
index e50ab8f..6d8e8f6 100644
--- a/MusicCommands/MusicPlayer.cs
+++ b/MusicCommands/MusicPlayer.cs
@@ -3,7 +3,6 @@ using System.IO;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
-using CMD_Utils.Music;
using PluginManager.Others;
namespace MusicCommands;
diff --git a/MusicCommands/Pause.cs b/MusicCommands/Pause.cs
index 035e8f7..8a86430 100644
--- a/MusicCommands/Pause.cs
+++ b/MusicCommands/Pause.cs
@@ -2,7 +2,7 @@
using Discord.WebSocket;
using PluginManager.Interfaces;
-namespace CMD_Utils.Music;
+namespace MusicCommands;
internal class Pause : DBCommand
{
diff --git a/MusicCommands/Play.cs b/MusicCommands/Play.cs
index 26d9a0f..0e9b181 100644
--- a/MusicCommands/Play.cs
+++ b/MusicCommands/Play.cs
@@ -5,11 +5,10 @@ using Discord;
using Discord.Audio;
using Discord.Commands;
using Discord.WebSocket;
-using MusicCommands;
using PluginManager.Interfaces;
using PluginManager.Others;
-namespace CMD_Utils.Music;
+namespace MusicCommands;
internal class Play : DBCommand
{
@@ -29,7 +28,7 @@ internal class Play : DBCommand
{
var path = "./Music";
var FileName = Functions.GetArguments(message).ToArray().MergeStrings(0);
- path += "/" + FileName + ".mp3";
+ path += "/" + FileName + ".ogg";
if (!File.Exists(path))
{
Console.WriteLine("Unknown path " + path);
diff --git a/MusicCommands/Unpause.cs b/MusicCommands/Unpause.cs
index cc004c7..cfe2040 100644
--- a/MusicCommands/Unpause.cs
+++ b/MusicCommands/Unpause.cs
@@ -1,5 +1,4 @@
-using CMD_Utils.Music;
-using Discord.Commands;
+using Discord.Commands;
using Discord.WebSocket;
using PluginManager.Interfaces;
diff --git a/MusicCommands/lplay.cs b/MusicCommands/lplay.cs
index 14e51b3..6adb117 100644
--- a/MusicCommands/lplay.cs
+++ b/MusicCommands/lplay.cs
@@ -1,5 +1,4 @@
-using CMD_Utils.Music;
-using Discord;
+using Discord;
using Discord.Audio;
using Discord.Commands;
using Discord.WebSocket;
diff --git a/PluginManager/Config.cs b/PluginManager/Config.cs
index 686fee4..985abc8 100644
--- a/PluginManager/Config.cs
+++ b/PluginManager/Config.cs
@@ -1,35 +1,117 @@
-using PluginManager.Others;
+using System;
+using PluginManager.Others;
using System.IO;
-using System.Linq;
using System.Text.Json;
using System.Threading.Tasks;
using System.Collections.Generic;
+using System.Threading;
+using Newtonsoft.Json.Linq;
namespace PluginManager
{
internal class AppConfig
{
- public Dictionary ApplicationVariables { get; set; }
- public List ProtectedKeyWords { get; set; }
+ public Dictionary? ApplicationVariables { get; set; }
+ public List? ProtectedKeyWords { get; set; }
}
public static class Config
{
- private static AppConfig appConfig;
+ public static class PluginConfig
+ {
+ public static List> InstalledPlugins = new();
+
+ public static void Load()
+ {
+ new Thread(LoadCommands).Start();
+ new Thread(LoadEvents).Start();
+ }
+
+ private static void LoadCommands()
+ {
+ string cmd_path = "./Data/Plugins/Commands/";
+ string[] files = Directory.GetFiles(cmd_path, $"*.{Loaders.PluginLoader.pluginCMDExtension}", SearchOption.AllDirectories);
+ foreach (var file in files)
+ if (!file.Contains("PluginManager", StringComparison.InvariantCultureIgnoreCase))
+ {
+ string PluginName = new FileInfo(file).Name;
+ string name = PluginName.Substring(0, PluginName.Length - 1 - PluginManager.Loaders.PluginLoader.pluginCMDExtension.Length);
+ InstalledPlugins.Add(new(name, PluginType.Command));
+ }
+ }
+
+ private static void LoadEvents()
+ {
+ string eve_path = "./Data/Plugins/Events/";
+ string[] files = Directory.GetFiles(eve_path, $"*.{Loaders.PluginLoader.pluginEVEExtension}", SearchOption.AllDirectories);
+ foreach (var file in files)
+ if (!file.Contains("PluginManager", StringComparison.InvariantCultureIgnoreCase))
+ if (!file.Contains("PluginManager", StringComparison.InvariantCultureIgnoreCase))
+ {
+ string PluginName = new FileInfo(file).Name;
+ string name = PluginName.Substring(0, PluginName.Length - 1 - PluginManager.Loaders.PluginLoader.pluginEVEExtension.Length);
+ InstalledPlugins.Add(new(name, PluginType.Event));
+ }
+ }
+
+ public static bool Contains(string pluginName)
+ {
+ foreach (var tuple in InstalledPlugins)
+ {
+ if (tuple.Item1 == pluginName) return true;
+ }
+
+ return false;
+ }
+
+ public static PluginType GetPluginType(string pluginName)
+ {
+ foreach (var tuple in InstalledPlugins)
+ {
+ if (tuple.Item1 == pluginName) return tuple.Item2;
+ }
+
+ return PluginType.Unknown;
+ }
+ }
+
+ private static AppConfig? appConfig { get; set; }
public static bool AddValueToVariables(string key, T value, bool isProtected)
{
- if (appConfig.ApplicationVariables.ContainsKey(key)) return false;
+ if (appConfig!.ApplicationVariables!.ContainsKey(key)) return false;
if (value == null) return false;
appConfig.ApplicationVariables.Add(key, value);
- if (isProtected) appConfig.ProtectedKeyWords.Add(key);
+ if (isProtected && key != "Version") appConfig.ProtectedKeyWords!.Add(key);
+
SaveConfig();
return true;
}
+ public static void GetAndAddValueToVariable(string key, string value, bool isReadOnly)
+ {
+ if (Config.ContainsKey(key)) return;
+ if (int.TryParse(value, out var intValue))
+ Config.AddValueToVariables(key, intValue, isReadOnly);
+ else if (bool.TryParse(value, out var boolValue))
+ Config.AddValueToVariables(key, boolValue, isReadOnly);
+ else if (float.TryParse(value, out var floatValue))
+ Config.AddValueToVariables(key, floatValue, isReadOnly);
+ else if (double.TryParse(value, out var doubleValue))
+ Config.AddValueToVariables(key, doubleValue, isReadOnly);
+ else if (uint.TryParse(value, out var uintValue))
+ Config.AddValueToVariables(key, uintValue, isReadOnly);
+ else if (long.TryParse(value, out var longValue))
+ Config.AddValueToVariables(key, longValue, isReadOnly);
+ else if (byte.TryParse(value, out var byteValue))
+ Config.AddValueToVariables(key, byteValue, isReadOnly);
+ else
+ Config.AddValueToVariables(key, value, isReadOnly);
+ }
+
public static T? GetValue(string key)
{
- if (!appConfig.ApplicationVariables.ContainsKey(key)) return default;
+ if (!appConfig!.ApplicationVariables!.ContainsKey(key)) return default;
try
{
JsonElement element = (JsonElement)appConfig.ApplicationVariables[key];
@@ -43,8 +125,8 @@ namespace PluginManager
public static bool SetValue(string key, T value)
{
- if (!appConfig.ApplicationVariables.ContainsKey(key)) return false;
- if (appConfig.ProtectedKeyWords.Contains(key)) return false;
+ if (!appConfig!.ApplicationVariables!.ContainsKey(key)) return false;
+ if (appConfig.ProtectedKeyWords!.Contains(key)) return false;
if (value == null) return false;
appConfig.ApplicationVariables[key] = JsonSerializer.SerializeToElement(value);
@@ -54,8 +136,9 @@ namespace PluginManager
public static bool RemoveKey(string key)
{
- appConfig.ApplicationVariables.Remove(key);
- appConfig.ProtectedKeyWords.Remove(key);
+ if (key == "Version" || key == "token" || key == "prefix") return false;
+ appConfig!.ApplicationVariables!.Remove(key);
+ appConfig.ProtectedKeyWords!.Remove(key);
SaveConfig();
return true;
}
@@ -63,7 +146,7 @@ namespace PluginManager
public static async void SaveConfig()
{
string path = Functions.dataFolder + "config.json";
- await Functions.SaveToJsonFile(path, appConfig);
+ await Functions.SaveToJsonFile(path, appConfig!);
}
public static async Task LoadConfig()
@@ -72,15 +155,15 @@ namespace PluginManager
if (File.Exists(path))
{
appConfig = await Functions.ConvertFromJson(path);
- Functions.WriteLogFile($"Loaded {appConfig.ApplicationVariables.Keys.Count} application variables.\nLoaded {appConfig.ProtectedKeyWords.Count} readonly variables.");
+ Functions.WriteLogFile($"Loaded {appConfig.ApplicationVariables!.Keys.Count} application variables.\nLoaded {appConfig.ProtectedKeyWords!.Count} readonly variables.");
}
else
appConfig = new() { ApplicationVariables = new Dictionary(), ProtectedKeyWords = new List() };
}
- public static bool ContainsValue(T value) => appConfig.ApplicationVariables.ContainsValue(value!);
- public static bool ContainsKey(string key) => appConfig.ApplicationVariables.ContainsKey(key);
+ public static bool ContainsValue(T value) => appConfig!.ApplicationVariables!.ContainsValue(value!);
+ public static bool ContainsKey(string key) => appConfig!.ApplicationVariables!.ContainsKey(key);
- public static Dictionary GetAllVariables() => new(appConfig.ApplicationVariables);
+ public static Dictionary GetAllVariables() => new(appConfig!.ApplicationVariables!);
}
}
diff --git a/PluginManager/Items/Command.cs b/PluginManager/Items/Command.cs
index 6850ece..ea8078b 100644
--- a/PluginManager/Items/Command.cs
+++ b/PluginManager/Items/Command.cs
@@ -1,4 +1,5 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
using Discord.WebSocket;
using PluginManager.Others;
@@ -42,3 +43,11 @@ internal class 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 5ac5947..0e88442 100644
--- a/PluginManager/Items/ConsoleCommandsHandler.cs
+++ b/PluginManager/Items/ConsoleCommandsHandler.cs
@@ -14,16 +14,15 @@ 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("https://raw.githubusercontent.com/Wizzy69/installer/discord-bot-files/Plugins.txt");
+ public static List commandList = new();
+ private readonly DiscordSocketClient? client;
public ConsoleCommandsHandler(DiscordSocketClient client)
{
this.client = client;
InitializeBasicCommands();
- Console.WriteLine("Initalized console command handeler !");
+ Console.WriteLine("Initialized console command handler !");
}
private void InitializeBasicCommands()
@@ -31,19 +30,35 @@ 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: " + command.Description);
+ Console.WriteLine("Command execution format:" + command.Usage);
return;
}
@@ -52,10 +67,11 @@ public class ConsoleCommandsHandler
}
);
+
AddCommand("lp", "Load plugins", () =>
{
if (pluginsLoaded) return;
- var loader = new PluginLoader(client);
+ var loader = new PluginLoader(client!);
loader.onCMDLoad += (name, typeName, success, exception) =>
{
Console.ForegroundColor = ConsoleColor.Green;
@@ -83,7 +99,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)
{
@@ -116,6 +132,12 @@ public class ConsoleCommandsHandler
else
path = $"./{info[1].Split('/')[info[1].Split('/').Length - 1]}";
await ServerCom.DownloadFileAsync(info[1], path);
+ if (info[0] == "Command" || info[0] == "Event")
+ if (info[0] == "Event")
+ Config.PluginConfig.InstalledPlugins.Add(new(name, PluginType.Event));
+ else if (info[0] == "Command") Config.PluginConfig.InstalledPlugins.Add(new(name, PluginType.Command));
+
+
Console.WriteLine("\n");
// check requirements if any
@@ -128,6 +150,7 @@ public class ConsoleCommandsHandler
foreach (var line in lines)
{
+ if (!(line.Length > 0 && line.Contains(","))) continue;
var split = line.Split(',');
Console.WriteLine($"\nDownloading item: {split[1]}");
await ServerCom.DownloadFileAsync(split[0], "./" + split[1]);
@@ -160,16 +183,6 @@ public class ConsoleCommandsHandler
Console.WriteLine("\n");
File.Delete("./" + split[1]);
}
-
- if (name == "DBUI")
- {
- Console.WriteLine("Reload with GUI ?[y/n]");
- if (Console.ReadKey().Key == ConsoleKey.Y)
- {
- Process.Start("./DiscordBotGUI.exe");
- Environment.Exit(0);
- }
- }
}
Console.WriteLine();
@@ -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];
@@ -197,23 +210,7 @@ public class ConsoleCommandsHandler
try
{
- if (Config.ContainsKey(key)) return;
- if (int.TryParse(value, out var intValue))
- Config.AddValueToVariables(key, intValue, isReadOnly);
- else if (bool.TryParse(value, out var boolValue))
- Config.AddValueToVariables(key, boolValue, isReadOnly);
- else if (float.TryParse(value, out var floatValue))
- Config.AddValueToVariables(key, floatValue, isReadOnly);
- else if (double.TryParse(value, out var doubleValue))
- Config.AddValueToVariables(key, doubleValue, isReadOnly);
- else if (uint.TryParse(value, out var uintValue))
- Config.AddValueToVariables(key, uintValue, isReadOnly);
- else if (long.TryParse(value, out var longValue))
- Config.AddValueToVariables(key, longValue, isReadOnly);
- else if (byte.TryParse(value, out var byteValue))
- Config.AddValueToVariables(key, byteValue, isReadOnly);
- else
- Config.AddValueToVariables(key, value, isReadOnly);
+ Config.GetAndAddValueToVariable(key, value, isReadOnly);
Console.WriteLine($"Updated config file with the following command: {args[1]} => {value}");
}
catch (Exception ex)
@@ -223,7 +220,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 +234,7 @@ public class ConsoleCommandsHandler
data.Add(new[] { "-", "-" });
data.Add(new[] { "Key", "Value" });
data.Add(new[] { "-", "-" });
- foreach (var kvp in d) data.Add(new[] { 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 +249,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 +281,30 @@ 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)
+ public bool HandleCommand(string command, bool removeCommandExecution = true)
{
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])
+ {
+ if (removeCommandExecution)
+ {
+ Console.SetCursorPosition(0, Console.CursorTop - 1);
+ for (int i = 0; i < command.Length; i++) Console.Write(" ");
+ Console.SetCursorPosition(0, Console.CursorTop);
+ }
+
+ Console.WriteLine();
+ item.Action(args);
+ return true;
+ }
+
+ return false;
+ //Console.WriteLine($"Executing: {args[0]} with the following parameters: {args.MergeStrings(1)}");
}
}
diff --git a/PluginManager/Items/Spinner.cs b/PluginManager/Items/Spinner.cs
deleted file mode 100644
index 910df5b..0000000
--- a/PluginManager/Items/Spinner.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-using System;
-using System.Threading.Tasks;
-using PluginManager.Others.Exceptions;
-
-namespace PluginManager.Items;
-
-public class Spinner
-{
- ///
- /// True if active, false otherwise
- ///
- public bool isSpinning;
-
- ///
- /// The Spinner constructor
- ///
- public Spinner()
- {
- isSpinning = false;
- }
-
- ///
- /// The method that is called to start spinning the spinner
- ///
- public async void Start()
- {
- isSpinning = true;
- var cnt = 0;
-
- while (isSpinning)
- {
- cnt++;
- switch (cnt % 4)
- {
- case 0:
- Console.Write("/");
- break;
- case 1:
- Console.Write("-");
- break;
- case 2:
- Console.Write("\\");
- break;
- case 3:
- Console.Write("|");
- break;
- }
-
- Console.SetCursorPosition(Console.CursorLeft - 1, Console.CursorTop);
- await Task.Delay(250);
- }
- }
-
- ///
- /// The method that is called to stop the spinner from spinning
- ///
- public void Stop()
- {
- if (!isSpinning) throw new APIException("Spinner was not spinning", GetType());
- isSpinning = false;
- }
-}
diff --git a/PluginManager/Loaders/Loader.cs b/PluginManager/Loaders/Loader.cs
index 1198eda..82aac6f 100644
--- a/PluginManager/Loaders/Loader.cs
+++ b/PluginManager/Loaders/Loader.cs
@@ -28,6 +28,11 @@ internal class Loader
private string path { get; }
private string extension { get; }
+
+ internal delegate void FileLoadedEventHandler(LoaderArgs args);
+
+ internal delegate void PluginLoadedEventHandler(LoaderArgs args);
+
internal event FileLoadedEventHandler? FileLoaded;
internal event PluginLoadedEventHandler? PluginLoaded;
@@ -100,8 +105,4 @@ internal class Loader
return list;
}
-
- internal delegate void FileLoadedEventHandler(LoaderArgs args);
-
- internal delegate void PluginLoadedEventHandler(LoaderArgs args);
}
diff --git a/PluginManager/Loaders/PluginLoader.cs b/PluginManager/Loaders/PluginLoader.cs
index c848f7f..6fdaf74 100644
--- a/PluginManager/Loaders/PluginLoader.cs
+++ b/PluginManager/Loaders/PluginLoader.cs
@@ -15,8 +15,8 @@ public class PluginLoader
private const string pluginCMDFolder = @"./Data/Plugins/Commands/";
private const string pluginEVEFolder = @"./Data/Plugins/Events/";
- private const string pluginCMDExtension = "dll";
- private const string pluginEVEExtension = "dll";
+ internal const string pluginCMDExtension = "dll";
+ internal const string pluginEVEExtension = "dll";
private readonly DiscordSocketClient _client;
///
@@ -87,11 +87,11 @@ public class PluginLoader
{
if (e.IsLoaded) ((DBEvent)e.Plugin!).Start(_client);
- if (onEVELoad != null) onEVELoad.Invoke(((DBEvent)e.Plugin!).name, e.TypeName!, e.IsLoaded, e.Exception);
+ onEVELoad?.Invoke(((DBEvent)e.Plugin!).name, e.TypeName!, e.IsLoaded, e.Exception);
}
private void OnCommandLoaded(LoaderArgs e)
{
- if (onCMDLoad != null) onCMDLoad.Invoke(((DBCommand)e.Plugin!).Command, e.TypeName!, e.IsLoaded, e.Exception);
+ onCMDLoad?.Invoke(((DBCommand)e.Plugin!).Command, e.TypeName!, e.IsLoaded, e.Exception);
}
}
diff --git a/PluginManager/Online/LanguageManager.cs b/PluginManager/Online/LanguageManager.cs
deleted file mode 100644
index fc24bad..0000000
--- a/PluginManager/Online/LanguageManager.cs
+++ /dev/null
@@ -1,82 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-using PluginManager.Others;
-
-namespace PluginManager.Online;
-
-public class LanguageManager
-{
- private readonly string link;
-
- ///
- /// The Language Manager constructor
- ///
- /// The link to where all the languages for the bot are stored
- public LanguageManager(string link)
- {
- this.link = link;
- }
-
- ///
- /// The method to list all languages
- ///
- ///
- public async Task ListAllLanguages()
- {
- try
- {
- var list = await ServerCom.ReadTextFromFile(link);
- var lines = list.ToArray();
-
- var info = new List();
- info.Add(new[] { "-", "-" });
- info.Add(new[] { "Language Name", "File Size" });
- info.Add(new[] { "-", "-" });
- foreach (var line in lines)
- {
- if (line.Length <= 2) continue;
- var d = line.Split(',');
- if (d[3].Contains("cp") || d[3].Contains("CrossPlatform")) info.Add(new[] { d[0], d[1] });
- }
-
- info.Add(new[] { "-", "-" });
- Console_Utilities.FormatAndAlignTable(info);
- }
-
- catch (Exception exception)
- {
- Console.WriteLine("Failed to execute command: listlang\nReason: " + exception.Message);
- Functions.WriteErrFile(exception.ToString());
- }
- }
-
- ///
- /// A function that gets the download link for specified language
- ///
- /// The name of the language
- ///
- public async Task GetDownloadLink(string langName)
- {
- try
- {
- var list = await ServerCom.ReadTextFromFile(link);
- var lines = list.ToArray();
-
- foreach (var line in lines)
- {
- if (line.Length <= 2) continue;
- var d = line.Split(',');
- if (d[0].Equals(langName) && (d[3].Contains("cp") || d[3].Contains("CrossPlatform"))) return new[] { d[2], d[3] };
- }
- }
- catch (Exception exception)
- {
- Console.WriteLine("Failed to execute command: listlang\nReason: " + exception.Message);
- Functions.WriteErrFile(exception.ToString());
- }
-
-
- return null;
- }
-}
diff --git a/PluginManager/Online/PluginsManager.cs b/PluginManager/Online/PluginsManager.cs
index 5f9dad6..d3bf569 100644
--- a/PluginManager/Online/PluginsManager.cs
+++ b/PluginManager/Online/PluginsManager.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using PluginManager.Others;
@@ -37,15 +37,15 @@ public class PluginsManager
var op = Functions.GetOperatingSystem();
var len = lines.Length;
- string[] titles = { "Name", "Description", "Plugin Type", "Libraries" };
- data.Add(new[] { "-", "-", "-", "-" });
+ string[] titles = { "Name", "Description", "Plugin Type", "Libraries", "Installed" };
+ data.Add(new[] { "-", "-", "-", "-", "-" });
data.Add(titles);
- data.Add(new[] { "-", "-", "-", "-" });
+ data.Add(new[] { "-", "-", "-", "-", "-" });
for (var i = 0; i < len; i++)
{
if (lines[i].Length <= 2) continue;
var content = lines[i].Split(',');
- var display = new string[4];
+ var display = new string[titles.Length];
if (op == OperatingSystem.WINDOWS)
{
if (content[4].Contains("Windows"))
@@ -58,6 +58,10 @@ public class PluginsManager
else
display[3] = "1";
+ if (Config.PluginConfig.Contains(content[0]) || Config.PluginConfig.Contains(content[0]))
+ display[4] = "✓";
+ else
+ display[4] = "X";
data.Add(display);
}
}
@@ -68,12 +72,17 @@ public class PluginsManager
display[0] = content[0];
display[1] = content[1];
display[2] = content[2];
+ if (content.Length == 6 && (content[5] != null || content[5].Length > 2)) display[3] = ((await ServerCom.ReadTextFromFile(content[5])).Count + 1).ToString();
+ if (Config.PluginConfig.Contains(content[0]) || Config.PluginConfig.Contains(content[0]))
+ display[4] = "✓";
+ else
+ display[4] = "X";
data.Add(display);
}
}
}
- data.Add(new[] { "-", "-", "-", "-" });
+ data.Add(new[] { "-", "-", "-", "-", "-" });
Console_Utilities.FormatAndAlignTable(data);
}
diff --git a/PluginManager/Others/Cryptography.cs b/PluginManager/Others/Cryptography.cs
deleted file mode 100644
index 04864ae..0000000
--- a/PluginManager/Others/Cryptography.cs
+++ /dev/null
@@ -1,88 +0,0 @@
-using System;
-using System.IO;
-using System.Security.Cryptography;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace PluginManager.Others;
-
-public class Cryptography
-{
- ///
- /// Translate hex to string
- ///
- /// The encrypted string
- ///
- public static string FromHexToString(string hexString)
- {
- var bytes = new byte[hexString.Length / 2];
- for (var i = 0; i < bytes.Length; i++) bytes[i] = Convert.ToByte(hexString.Substring(i * 2, 2), 16);
-
- return Encoding.Unicode.GetString(bytes);
- }
-
- ///
- /// Translate string to hex
- ///
- /// The string to encrypt
- ///
- public static string ToHexString(string str)
- {
- var sb = new StringBuilder();
-
- var bytes = Encoding.Unicode.GetBytes(str);
- foreach (var t in bytes) sb.Append(t.ToString("X2"));
-
- return sb.ToString();
- }
-
- ///
- /// Create MD5 hash
- ///
- /// The text to encrypt
- ///
- public static async Task CreateMD5(string text)
- {
- var output = "";
- using (var md5 = MD5.Create())
- {
- using (var s = GenerateStreamFromString(text))
- {
- var t = await md5.ComputeHashAsync(s);
- output = Convert.ToBase64String(t);
- }
- }
-
- return output;
- }
-
- ///
- /// Create SHA256 hash
- ///
- /// The text to encrypt
- ///
- public static async Task CreateSHA256(string text)
- {
- var output = "";
- using (var sha = SHA256.Create())
- {
- using (var s = GenerateStreamFromString(text))
- {
- var t = await sha.ComputeHashAsync(s);
- output = Convert.ToBase64String(t);
- }
- }
-
- return output;
- }
-
- private static Stream GenerateStreamFromString(string s)
- {
- var stream = new MemoryStream();
- var writer = new StreamWriter(stream);
- writer.Write(s);
- writer.Flush();
- stream.Position = 0;
- return stream;
- }
-}
diff --git a/PluginManager/Others/Enums.cs b/PluginManager/Others/Enums.cs
index d8b22fb..c516802 100644
--- a/PluginManager/Others/Enums.cs
+++ b/PluginManager/Others/Enums.cs
@@ -1,4 +1,6 @@
-namespace PluginManager.Others;
+using PluginManager.Interfaces;
+
+namespace PluginManager.Others;
///
/// A list of operating systems
@@ -20,3 +22,8 @@ public enum Error
/// The output log type
///
public enum OutputLogLevel { NONE, INFO, WARNING, ERROR, CRITICAL }
+
+///
+/// Plugin Type
+///
+public enum PluginType { Command, Event, Unknown }
\ No newline at end of file
diff --git a/PluginManager/Others/Exceptions/APIException.cs b/PluginManager/Others/Exceptions/APIException.cs
deleted file mode 100644
index 37264c1..0000000
--- a/PluginManager/Others/Exceptions/APIException.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-using System;
-
-namespace PluginManager.Others.Exceptions;
-
-///
-/// Custom Exception for PluginManager
-///
-[Serializable]
-public class APIException : Exception
-{
- ///
- /// The APIException contructor
- ///
- /// The error message
- /// The function where the message was triggered
- /// The possible cause of the error
- /// The error code
- public APIException(string message, string? function, string possible_cause, Error error) : base(message)
- {
- ErrorCode = error;
- Function = function;
- PossibleCause = possible_cause;
- }
-
- ///
- /// The APIException contructor
- ///
- /// The error message
- /// The function where the message was triggered
- /// The error code
- public APIException(string message, string? function, Error? errorCode) : base(message)
- {
- ErrorCode = errorCode;
- Function = function;
- }
-
- ///
- /// The APIException contructor
- ///
- /// The error message
- /// The function where the message was triggered
- public APIException(string message, string? function) : base(message)
- {
- Function = function;
- }
-
- ///
- /// The APIException contructor
- ///
- /// The error message
- public APIException(string message) : base(message)
- {
- }
-
- ///
- /// The APIException constructor
- ///
- /// The error message
- /// The class where the error was thrown
- public APIException(string message, Type errorLocation) : base(message)
- {
- Function = errorLocation.FullName;
- }
-
- ///
- /// The function where the error occurred
- ///
- public string? Function { get; } = "not specified";
-
- ///
- /// The error code
- ///
- public Error? ErrorCode { get; } = Error.UNKNOWN_ERROR;
-
- ///
- /// The possible cause that determined the error
- ///
- public string? PossibleCause { get; } = "not specified";
-
- ///
- /// Method to print the error to
- ///
- public void Print()
- {
- Console.WriteLine("Message Content: " + Message);
- Console.WriteLine("Function: " + Function);
- Console.WriteLine("Error Code: " + ErrorCode);
- Console.WriteLine("Possible cause: " + PossibleCause);
- if (StackTrace != null) Functions.WriteErrFile(StackTrace);
- }
-}
diff --git a/PluginManager/Others/Functions.cs b/PluginManager/Others/Functions.cs
index 0857eb1..c1df251 100644
--- a/PluginManager/Others/Functions.cs
+++ b/PluginManager/Others/Functions.cs
@@ -32,15 +32,10 @@ namespace PluginManager.Others
///
public static readonly string errFolder = @"./Output/Errors/";
- ///
- /// The location for all languages
- ///
- public static readonly string langFolder = @"./Data/Languages/";
-
///
/// Archives folder
///
- public static readonly string pakFolder = @"./Data/Resources/PAKS/";
+ public static readonly string pakFolder = @"./Data/Resources/PAK/";
///
@@ -49,13 +44,13 @@ namespace PluginManager.Others
/// The file name that is inside the archive or its full path
/// The archive location from the PAKs folder
/// A string that represents the content of the file or null if the file does not exists or it has no content
- public static async Task ReadFromPakAsync(string FileName, string archFile)
+ public static async Task ReadFromPakAsync(string FileName, string archFile)
{
archFile = pakFolder + archFile;
Directory.CreateDirectory(pakFolder);
if (!File.Exists(archFile)) throw new FileNotFoundException("Failed to load file !");
- string? textValue = null;
+ Stream? textValue = null;
var fs = new FileStream(archFile, FileMode.Open);
var zip = new ZipArchive(fs, ZipArchiveMode.Read);
foreach (var entry in zip.Entries)
@@ -64,7 +59,8 @@ namespace PluginManager.Others
{
Stream s = entry.Open();
StreamReader reader = new StreamReader(s);
- textValue = await reader.ReadToEndAsync();
+ textValue = reader.BaseStream;
+ textValue.Position = 0;
reader.Close();
s.Close();
fs.Close();
@@ -239,7 +235,9 @@ namespace PluginManager.Others
///
public static async Task SaveToJsonFile(string file, T Data)
{
- using (var s = File.OpenWrite(file)) await JsonSerializer.SerializeAsync(s, Data, typeof(T), new JsonSerializerOptions { WriteIndented = true });
+ var s = File.OpenWrite(file);
+ await JsonSerializer.SerializeAsync(s, Data, typeof(T), new JsonSerializerOptions { WriteIndented = true });
+ s.Close();
}
///
@@ -259,7 +257,36 @@ namespace PluginManager.Others
text.Position = 0;
var obj = await JsonSerializer.DeserializeAsync(text);
text.Close();
- return obj;
+ 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)
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 @@
-
+