mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-04-20 00:43:36 +03:00
Resolve conversations
Signed-off-by: Macintosh II <mctaylxrs@outlook.com>
This commit is contained in:
parent
5f67718fa1
commit
a6e4832118
2 changed files with 10 additions and 7 deletions
|
@ -9,7 +9,7 @@ using Remora.Results;
|
|||
namespace Octobot.Responders;
|
||||
|
||||
/// <summary>
|
||||
/// Handles removing guild ID from <see cref="GuildData" /> if bot leaves the guild.
|
||||
/// Handles removing guild ID from <see cref="GuildData" /> if the guild becomes unavailable.
|
||||
/// </summary>
|
||||
[UsedImplicitly]
|
||||
public class GuildUnloadedResponder : IResponder<IGuildDelete>
|
||||
|
@ -24,12 +24,15 @@ public class GuildUnloadedResponder : IResponder<IGuildDelete>
|
|||
_logger = logger;
|
||||
}
|
||||
|
||||
public async Task<Result> RespondAsync(IGuildDelete gatewayEvent, CancellationToken ct = default)
|
||||
public Task<Result> RespondAsync(IGuildDelete gatewayEvent, CancellationToken ct = default)
|
||||
{
|
||||
var guildId = gatewayEvent.ID;
|
||||
await _guildData.RemoveGuildId(guildId);
|
||||
_logger.LogInformation("Left guild {guildId}", guildId);
|
||||
var removeGuildSucceed = _guildData.RemoveGuildId(guildId);
|
||||
if (removeGuildSucceed)
|
||||
{
|
||||
_logger.LogInformation("Left guild {GuildId}", guildId);
|
||||
}
|
||||
|
||||
return Result.FromSuccess();
|
||||
return Task.FromResult(Result.FromSuccess());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -143,8 +143,8 @@ public sealed class GuildDataService : IHostedService
|
|||
return _datas.Keys;
|
||||
}
|
||||
|
||||
public Task RemoveGuildId(Snowflake id)
|
||||
public bool RemoveGuildId(Snowflake id)
|
||||
{
|
||||
return Task.FromResult(_datas.TryRemove(id, out _));
|
||||
return _datas.TryRemove(id, out _);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue