init
This commit is contained in:
commit
ded4f4db26
43 changed files with 2052 additions and 0 deletions
27
Catalogger.Backend/Bot/Responders/ReadyResponder.cs
Normal file
27
Catalogger.Backend/Bot/Responders/ReadyResponder.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
using Catalogger.Backend.Extensions;
|
||||
using Catalogger.Backend.Services;
|
||||
using Remora.Discord.API.Abstractions.Gateway.Events;
|
||||
using Remora.Discord.Gateway.Responders;
|
||||
using Remora.Results;
|
||||
|
||||
namespace Catalogger.Backend.Bot.Responders;
|
||||
|
||||
public class ReadyResponder(ILogger logger, WebhookExecutorService webhookExecutorService, Config config)
|
||||
: IResponder<IReady>
|
||||
{
|
||||
private readonly ILogger _logger = logger.ForContext<ReadyResponder>();
|
||||
|
||||
public Task<Result> RespondAsync(IReady gatewayEvent, CancellationToken ct = default)
|
||||
{
|
||||
var shardId = gatewayEvent.Shard.TryGet(out var shard) ? (shard.ShardID, shard.ShardCount) : (0, 1);
|
||||
_logger.Information("Ready as {User} on shard {ShardId} / {ShardCount}", gatewayEvent.User.Tag(), shardId.Item1,
|
||||
shardId.Item2);
|
||||
if (shardId.Item1 == 0) webhookExecutorService.SetSelfUser(gatewayEvent.User);
|
||||
// Sanity check
|
||||
var appId = gatewayEvent.Application.ID.ToUlong();
|
||||
_logger.Debug("Application ID is {ApplicationId}, is same as config? {SameAsConfig}", appId,
|
||||
appId == config.Discord.ApplicationId);
|
||||
|
||||
return Task.FromResult(Result.Success);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue