diff --git a/.gitignore b/.gitignore index c82094e..9b8178a 100644 --- a/.gitignore +++ b/.gitignore @@ -371,6 +371,5 @@ FodyWeavers.xsd /DiscordBot.rar /DiscordBot/Data/ /DiscordBot/Updater/ -.vscode/ .idea/ /DiscordBotWeb/ \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..0928561 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,42 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (web)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceFolder}/DiscordBotPlugins/DiscordBotUI/bin/Debug/net7.0/DiscordBotUI.exe", + "args": [], + "cwd": "${workspaceFolder}/DiscordBotPlugins/DiscordBotUI/bin/Debug/net7.0", + "stopAtEntry": false, + "console": "externalTerminal", + "serverReadyAction": { + "action": "openExternally", + "pattern": "\\bNow listening on:\\s+(https?://\\S+)" + }, + "env": { + "ASPNETCORE_ENVIRONMENT": "Development" + }, + "sourceFileMap": { + "/Views": "${workspaceFolder}/Views" + } + }, + { + // 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/net6.0/DiscordBot.exe", + "args": [], + "cwd": "${workspaceFolder}/DiscordBot/bin/Debug/net6.0", + // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console + "console": "externalTerminal", + "stopAtEntry": false + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..08f8fa7 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,41 @@ +{ + "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", + "--project", + "${workspaceFolder}/DiscordBot/DiscordBot.csproj" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/DiscordBotPlugins/DiscordBotUI/Program.cs b/DiscordBotPlugins/DiscordBotUI/Program.cs index 037bd84..c95d776 100644 --- a/DiscordBotPlugins/DiscordBotUI/Program.cs +++ b/DiscordBotPlugins/DiscordBotUI/Program.cs @@ -34,4 +34,12 @@ app.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); +app.Lifetime.ApplicationStopping.Register(async () => +{ + await Task.Run(() => { + PluginManager.Logger.Log("Stopping bot..."); + PluginManager.Config.Data.Save(); + PluginManager.Config.Plugins.Save(); + }); +}); app.Run(); \ No newline at end of file