1
0
Fork 1
mirror of https://github.com/TeamOctolings/Octobot.git synced 2025-04-20 00:43:36 +03:00
Octobot/src/Responders/GuildMemberRolesUpdatedResponder.cs
Octol1ttle c654857bf1
Update .editorconfig and reformat code
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
2023-08-02 23:43:47 +05:00

29 lines
No EOL
944 B
C#

using Boyfriend.Data;
using Boyfriend.Services;
using JetBrains.Annotations;
using Remora.Discord.API.Abstractions.Gateway.Events;
using Remora.Discord.Gateway.Responders;
using Remora.Results;
namespace Boyfriend.Responders;
/// <summary>
/// Handles updating <see cref="MemberData.Roles" /> when a guild member is updated.
/// </summary>
[UsedImplicitly]
public class GuildMemberUpdateResponder : IResponder<IGuildMemberUpdate>
{
private readonly GuildDataService _guildData;
public GuildMemberUpdateResponder(GuildDataService guildData)
{
_guildData = guildData;
}
public async Task<Result> RespondAsync(IGuildMemberUpdate gatewayEvent, CancellationToken ct = default)
{
var memberData = await _guildData.GetMemberData(gatewayEvent.GuildID, gatewayEvent.User.ID, ct);
memberData.Roles = gatewayEvent.Roles.ToList().ConvertAll(r => r.Value);
return Result.FromSuccess();
}
}