bot: trace startup sequence to stdout
This commit is contained in:
parent
e7fa5625b6
commit
0d6b6bf08e
32
.vscode/launch.json
vendored
32
.vscode/launch.json
vendored
@ -1,16 +1,28 @@
|
||||
{
|
||||
// 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": [
|
||||
// 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
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "PluralKit",
|
||||
"type": "python",
|
||||
"name": ".NET Core Launch (console)",
|
||||
"type": "coreclr",
|
||||
"request": "launch",
|
||||
"program": "${workspaceRoot}/src/bot_main.py",
|
||||
"args": ["${workspaceRoot}/pluralkit.conf"],
|
||||
"console": "integratedTerminal",
|
||||
"preLaunchTask": "build",
|
||||
// If you have changed target frameworks, make sure to update the program path.
|
||||
"program": "${workspaceFolder}/bin/Debug/netcoreapp2.2/PluralKit.dll",
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}",
|
||||
// For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
|
||||
"console": "internalConsole",
|
||||
"stopAtEntry": false,
|
||||
"envFile": "${workspaceFolder}/.env"
|
||||
},
|
||||
{
|
||||
"name": ".NET Core Attach",
|
||||
"type": "coreclr",
|
||||
"request": "attach",
|
||||
"processId": "${command:pickProcess}"
|
||||
}
|
||||
]
|
||||
}
|
@ -23,6 +23,8 @@ namespace PluralKit
|
||||
|
||||
private async Task MainAsync()
|
||||
{
|
||||
Console.WriteLine("Starting PluralKit...");
|
||||
|
||||
// Dapper by default tries to pass ulongs to Npgsql, which rejects them since PostgreSQL technically
|
||||
// doesn't support unsigned types on its own.
|
||||
// Instead we add a custom mapper to encode them as signed integers instead, converting them back and forth.
|
||||
@ -32,15 +34,19 @@ namespace PluralKit
|
||||
|
||||
using (var services = BuildServiceProvider())
|
||||
{
|
||||
Console.WriteLine("- Connecting to database...");
|
||||
var connection = services.GetRequiredService<IDbConnection>() as NpgsqlConnection;
|
||||
connection.ConnectionString = Environment.GetEnvironmentVariable("PK_DATABASE_URI");
|
||||
await connection.OpenAsync();
|
||||
|
||||
Console.WriteLine("- Connecting to Discord...");
|
||||
var client = services.GetRequiredService<IDiscordClient>() as DiscordSocketClient;
|
||||
await client.LoginAsync(TokenType.Bot, Environment.GetEnvironmentVariable("PK_TOKEN"));
|
||||
await client.StartAsync();
|
||||
|
||||
Console.WriteLine("- Initializing bot...");
|
||||
await services.GetRequiredService<Bot>().Init();
|
||||
|
||||
await Task.Delay(-1);
|
||||
}
|
||||
}
|
||||
@ -85,11 +91,19 @@ namespace PluralKit
|
||||
_commands.CommandExecuted += CommandExecuted;
|
||||
await _commands.AddModulesAsync(Assembly.GetEntryAssembly(), _services);
|
||||
|
||||
_client.Ready += Ready;
|
||||
_client.MessageReceived += MessageReceived;
|
||||
_client.ReactionAdded += _proxy.HandleReactionAddedAsync;
|
||||
_client.MessageDeleted += _proxy.HandleMessageDeletedAsync;
|
||||
}
|
||||
|
||||
private Task Ready()
|
||||
{
|
||||
Console.WriteLine($"Shard #{_client.ShardId} connected to {_client.Guilds.Sum(g => g.Channels.Count)} channels in {_client.Guilds.Count} guilds.");
|
||||
Console.WriteLine($"PluralKit started as {_client.CurrentUser.Username}#{_client.CurrentUser.Discriminator} ({_client.CurrentUser.Id}).");
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private async Task CommandExecuted(Optional<CommandInfo> cmd, ICommandContext ctx, IResult _result)
|
||||
{
|
||||
if (!_result.IsSuccess) {
|
||||
|
Loading…
Reference in New Issue
Block a user