/// <inheritdoc /> public async Task AddDesignatedChannelAsync(IGuild guild, IMessageChannel logChannel, DesignatedChannelType type) { AuthorizationService.RequireClaims(AuthorizationClaim.DesignatedChannelMappingCreate); using (var transaction = await DesignatedChannelMappingRepository.BeginCreateTransactionAsync()) { if (await DesignatedChannelMappingRepository.AnyAsync(new DesignatedChannelMappingSearchCriteria() { GuildId = guild.Id, ChannelId = logChannel.Id, IsDeleted = false, Type = type })) { throw new InvalidOperationException($"{logChannel.Name} in {guild.Name} is already assigned to {type}"); } await DesignatedChannelMappingRepository.CreateAsync(new DesignatedChannelMappingCreationData() { GuildId = guild.Id, ChannelId = logChannel.Id, CreatedById = AuthorizationService.CurrentUserId.Value, Type = type }); transaction.Commit(); } }
/// <inheritdoc /> public Task <bool> AnyDesignatedChannelAsync(ulong guildId, DesignatedChannelType type) => DesignatedChannelMappingRepository.AnyAsync(new DesignatedChannelMappingSearchCriteria() { GuildId = guildId, Type = type, IsDeleted = false });
/// <inheritdoc /> public Task <bool> ChannelHasDesignationAsync( ulong guildId, ulong channelId, DesignatedChannelType designation, CancellationToken cancellationToken) => DesignatedChannelMappingRepository.AnyAsync(new DesignatedChannelMappingSearchCriteria() { GuildId = guildId, Type = designation, ChannelId = channelId, IsDeleted = false }, cancellationToken);