05ca8061e9
PR Checks / test-and-build (pull_request) Successful in 5m46s
Add a separate GmRelay.DiscordBot worker using NetCord Gateway with startup token validation, PostgreSQL datasource registration, slash-command setup, component interaction service registration, and lifecycle logging. Wire the Discord service through Aspire AppHost, Docker Compose, PR checks, deploy image build/push/scan/pull steps, README docs, and synchronized version 2.2.0. Add TDD coverage for project isolation, token validation, startup wiring, runtime wiring, and version synchronization. Bump version -> 2.2.0
44 lines
1.2 KiB
C#
44 lines
1.2 KiB
C#
using NetCord.Gateway;
|
|
using NetCord.Hosting.Gateway;
|
|
|
|
namespace GmRelay.DiscordBot.Infrastructure.Logging;
|
|
|
|
public sealed class DiscordGatewayLifecycleLogger(
|
|
ILogger<DiscordGatewayLifecycleLogger> logger)
|
|
: IConnectGatewayHandler,
|
|
IReadyGatewayHandler,
|
|
IDisconnectGatewayHandler,
|
|
IResumeGatewayHandler
|
|
{
|
|
public ValueTask HandleAsync()
|
|
{
|
|
logger.LogInformation("Discord gateway connected");
|
|
return ValueTask.CompletedTask;
|
|
}
|
|
|
|
public ValueTask HandleAsync(ReadyEventArgs arg)
|
|
{
|
|
logger.LogInformation(
|
|
"Discord gateway ready for application {ApplicationId} in {GuildCount} guilds",
|
|
arg.ApplicationId,
|
|
arg.GuildIds.Count);
|
|
|
|
return ValueTask.CompletedTask;
|
|
}
|
|
|
|
public ValueTask HandleAsync(DisconnectEventArgs arg)
|
|
{
|
|
logger.LogWarning(
|
|
"Discord gateway disconnected; reconnect scheduled: {Reconnect}",
|
|
arg.Reconnect);
|
|
|
|
return ValueTask.CompletedTask;
|
|
}
|
|
|
|
ValueTask IResumeGatewayHandler.HandleAsync()
|
|
{
|
|
logger.LogInformation("Discord gateway session resumed");
|
|
return ValueTask.CompletedTask;
|
|
}
|
|
}
|