public async Task <ServiceResponse> AddPattern(ulong guildId, string regexPattern, MessageContentPatternType patternType) { if (!_authorizationService.HasClaim(AuthorizationClaim.ManageMessageContentPatterns)) { return(ServiceResponse.Fail("User does not have claim to manage patterns!")); } if (!IsValidRegex(regexPattern)) { return(ServiceResponse.Fail("Pattern is not a valid Regex!")); } if (await DoesPatternExist(guildId, regexPattern)) { return(ServiceResponse.Fail("Pattern already exists!")); } var entity = new MessageContentPatternEntity { GuildId = guildId, Pattern = regexPattern, PatternType = patternType, }; _db.Add(entity); await _db.SaveChangesAsync(); ClearCacheForGuild(guildId); return(ServiceResponse.Ok()); }