fix: remove unnecessary async methods, fix PluralkitApiService

This commit is contained in:
sam 2024-09-02 15:59:16 +02:00
parent 086eb95452
commit db01f879bd
Signed by: sam
GPG key ID: 5F3C3C1B3166639D
10 changed files with 96 additions and 73 deletions

View file

@ -61,7 +61,7 @@ public class GuildCreateResponder(
_logger.Information("Joined new guild {GuildName} / {GuildId}", guildName, guildId);
if (config.Discord.GuildLogId != null && evt.Guild.IsT0)
await webhookExecutor.QueueLogAsync(config.Discord.GuildLogId.Value, new EmbedBuilder()
webhookExecutor.QueueLog(config.Discord.GuildLogId.Value, new EmbedBuilder()
.WithTitle("Joined new guild")
.WithDescription($"Joined new guild **{guild.Name}**")
.WithFooter($"ID: {guild.ID}")
@ -75,24 +75,24 @@ public class GuildCreateResponder(
return Result.Success;
}
public async Task<Result> RespondAsync(IGuildDelete evt, CancellationToken ct = default)
public Task<Result> RespondAsync(IGuildDelete evt, CancellationToken ct = default)
{
if (evt.IsUnavailable.OrDefault(false))
{
_logger.Debug("Guild {GuildId} became unavailable", evt.ID);
return Result.Success;
return Task.FromResult(Result.Success);
}
if (!guildCache.TryGet(evt.ID, out var guild))
{
_logger.Information("Left uncached guild {GuildId}", evt.ID);
return Result.Success;
return Task.FromResult(Result.Success);
}
_logger.Information("Left guild {GuildName} / {GuildId}", guild.Name, guild.ID);
if (config.Discord.GuildLogId != null)
await webhookExecutor.QueueLogAsync(config.Discord.GuildLogId.Value, new EmbedBuilder()
webhookExecutor.QueueLog(config.Discord.GuildLogId.Value, new EmbedBuilder()
.WithTitle("Left guild")
.WithDescription($"Left guild **{guild.Name}**")
.WithFooter($"ID: {guild.ID}")
@ -103,6 +103,6 @@ public class GuildCreateResponder(
.Build()
.GetOrThrow());
return Result.Success;
return Task.FromResult(Result.Success);
}
}