commit 075c824b90b9c7f41cce71d21658e7c3a7f62e76 Author: ModZero Date: Wed Oct 11 16:34:22 2023 +0200 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9b809e8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,39 @@ +*.swp +*.*~ +project.lock.json +.DS_Store +*.pyc +nupkg/ + +# Visual Studio Code +/.vscode/**/* +!/.vscode/launch.json +!/.vscode/tasks.json + +# Rider +.idea + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +build/ +bld/ +[Bb]in/ +[Oo]bj/ +[Oo]ut/ +msbuild.log +msbuild.err +msbuild.wrn + +# Visual Studio 2015 +.vs/ \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..ef9e1d4 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,21 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [{ + "name": "God Replacement Product", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "dotnet: build", + "program": "${workspaceFolder}/GodReplacementProduct/bin/Debug/net7.0/GodReplacementProduct.dll", + "args": [], + "env": { + "DOTNET_ENVIRONMENT": "Development" + }, + "cwd": "${workspaceFolder}", + "stopAtEntry": false, + "console": "internalConsole" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000..b1a72f6 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,17 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "dotnet", + "task": "build", + "problemMatcher": [ + "$msCompile" + ], + "group": { + "kind": "build", + "isDefault": true + }, + "label": "dotnet: build" + } + ] +} \ No newline at end of file diff --git a/GodReplacementProduct.sln b/GodReplacementProduct.sln new file mode 100644 index 0000000..fe161f1 --- /dev/null +++ b/GodReplacementProduct.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GodReplacementProduct", "GodReplacementProduct\GodReplacementProduct.csproj", "{D1FB24F7-9C02-4748-8FF9-52C2F0F95167}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D1FB24F7-9C02-4748-8FF9-52C2F0F95167}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D1FB24F7-9C02-4748-8FF9-52C2F0F95167}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D1FB24F7-9C02-4748-8FF9-52C2F0F95167}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D1FB24F7-9C02-4748-8FF9-52C2F0F95167}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/GodReplacementProduct/GodReplacementProduct.csproj b/GodReplacementProduct/GodReplacementProduct.csproj new file mode 100644 index 0000000..a10f43c --- /dev/null +++ b/GodReplacementProduct/GodReplacementProduct.csproj @@ -0,0 +1,19 @@ + + + + Exe + net7.0 + enable + enable + 25724376-26fa-4834-85fa-cac34198a3c3 + + + + + + + + + + + diff --git a/GodReplacementProduct/Program.cs b/GodReplacementProduct/Program.cs new file mode 100644 index 0000000..6430684 --- /dev/null +++ b/GodReplacementProduct/Program.cs @@ -0,0 +1,61 @@ +using Discord; +using Discord.WebSocket; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; + +namespace GodReplacementProduct; + +public class Program +{ + static void Main(string[] args) { + var builder = Host.CreateApplicationBuilder(args); + + builder.Services.AddHostedService(); + + var config = new DiscordSocketConfig() + { + }; + builder.Services.AddSingleton(config); + builder.Services.AddSingleton(); + + var host = builder.Build(); + host.Run(); + } +} + +public sealed class GodReplacementBot : IHostedService { + private readonly ILogger _logger; + private readonly IConfiguration _config; + private readonly DiscordSocketClient _client; + + public GodReplacementBot( + ILogger logger, + IConfiguration config, + DiscordSocketClient client + ) { + _logger = logger; + _config = config; + _client = client; + } + + public async Task StartAsync(CancellationToken cancellationToken) { + _client.Log += Log; + var token = _config.GetValue("GodReplacementProject:DiscordToken"); + + await _client.LoginAsync(TokenType.Bot, token); + await _client.StartAsync(); + + await Task.Delay(Timeout.Infinite); + } + + public async Task StopAsync(CancellationToken cancellationToken) { + await _client.StopAsync(); + } + + private Task Log(LogMessage msg) { + Console.WriteLine(msg.ToString()); + return Task.CompletedTask; + } +}