Initial commit
This commit is contained in:
commit
075c824b90
39
.gitignore
vendored
Normal file
39
.gitignore
vendored
Normal file
@ -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/
|
21
.vscode/launch.json
vendored
Normal file
21
.vscode/launch.json
vendored
Normal file
@ -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"
|
||||
}
|
||||
]
|
||||
}
|
17
.vscode/tasks.json
vendored
Normal file
17
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"type": "dotnet",
|
||||
"task": "build",
|
||||
"problemMatcher": [
|
||||
"$msCompile"
|
||||
],
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
},
|
||||
"label": "dotnet: build"
|
||||
}
|
||||
]
|
||||
}
|
22
GodReplacementProduct.sln
Normal file
22
GodReplacementProduct.sln
Normal file
@ -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
|
19
GodReplacementProduct/GodReplacementProduct.csproj
Normal file
19
GodReplacementProduct/GodReplacementProduct.csproj
Normal file
@ -0,0 +1,19 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net7.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<UserSecretsId>25724376-26fa-4834-85fa-cac34198a3c3</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Discord.Net" Version="3.12.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
61
GodReplacementProduct/Program.cs
Normal file
61
GodReplacementProduct/Program.cs
Normal file
@ -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<GodReplacementBot>();
|
||||
|
||||
var config = new DiscordSocketConfig()
|
||||
{
|
||||
};
|
||||
builder.Services.AddSingleton(config);
|
||||
builder.Services.AddSingleton<DiscordSocketClient>();
|
||||
|
||||
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<GodReplacementBot> logger,
|
||||
IConfiguration config,
|
||||
DiscordSocketClient client
|
||||
) {
|
||||
_logger = logger;
|
||||
_config = config;
|
||||
_client = client;
|
||||
}
|
||||
|
||||
public async Task StartAsync(CancellationToken cancellationToken) {
|
||||
_client.Log += Log;
|
||||
var token = _config.GetValue<string>("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;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user