/// <inheritdoc /> public async Task <Result> RespondAsync(IMessageReactionRemove gatewayEvent, CancellationToken ct = default) { if (!gatewayEvent.GuildID.IsDefined(out var guildID)) { return(Result.FromSuccess()); } var user = gatewayEvent.UserID; return(await UpdateTimestampAndRelevantAutorolesAsync(guildID, user, ct)); }
/// <inheritdoc /> public async Task <Result> RespondAsync(IMessageReactionRemove gatewayEvent, CancellationToken ct = default) { if (!gatewayEvent.GuildID.IsDefined(out var guildID)) { return(Result.FromSuccess()); } var autoroles = await _autoroles.GetAutorolesAsync ( guildID, q => q .Where(a => a.IsEnabled) .Where ( a => a.Conditions.Any ( c => c is ReactionCondition && ((ReactionCondition)c).MessageID == gatewayEvent.MessageID && ((ReactionCondition)c).ChannelID == gatewayEvent.ChannelID && ((ReactionCondition)c).EmoteName == gatewayEvent.Emoji.Name ) ), ct ); var user = gatewayEvent.UserID; foreach (var autorole in autoroles) { using var transaction = TransactionFactory.Create(); var updateAutorole = await _autoroleUpdates.UpdateAutoroleForUserAsync(autorole, guildID, user, ct); if (!updateAutorole.IsSuccess) { return(Result.FromError(updateAutorole)); } transaction.Complete(); } return(Result.FromSuccess()); }